- Project Overview
- Mandatory Features
- Project Compilation and Execution
- Tests - Usage Examples
- Copyright
The push_swap
project is an algorithm challenge aiming to sort a stack of integers using the least possible number of operations, adhering to a specified set of allowed operations.
This repository does not have a checker, so it is necessary for the sorting test to be carried out by third-party testers or by the checker provided by 42.
- Efficient algorithm to sort the stack.
- Limited set of operations:
sa
,sb
,ss
,pa
,pb
,ra
,rb
,rr
,rra
,rrb
,rrr
.
#Compilation
make
#Execution option 1:
ARG="3 5 2 1 4"; ./push_swap $ARG
#[...list of operations...]
#Execution option 2:
./push_swap 3 5 2 1 4
#[...list of operations...]
#Test counting the amount of movements:
ARG="3 5 2 1 4"; ./push_swap $ARG | wc -l
#[...amount of operations...]
#Test counting the amount of movements:
./push_swap 3 5 2 1 4 | wc -l
#[...amount of operations...]
#Test with sort checker:
ARG="3 5 2 1 4"; ./push_swap $ARG | ./checker $ARG
#OK
#Test with non-integer:
./push_swap 3 5 2 one 4
#Error
./push_swap 3 5 2 -2147483649 4
#Error
./push_swap 3 5 2 2147483649 4
#Error
./push_swap 3 5 2 --2 4
#Error
./push_swap 3 5 2 -+2 4
#Error
./push_swap 3 5 2 - 4
#Error