The seventh project in the 42sp fundamentals track, Push Swap, is based on the creation of a program that receives as parameter a stack (ordered or not) and sorts it by ascending order, using only a set of specific movements (SA, SB, SS, PA, PB, RA, RB, RR, RRA, RRB, RRR). The main objective of this project is to introduce the concept of complexity and sorting algorithms.
- Make sure you clone the repository with the following command:
$> git clone [email protected]:ArthurSobreira/42_push_swap.git
- Once cloned, to compile the program, use the following commands:
$> make / make bonus
- To run the mandatory part of the program, you just need to have access to a stack, and pass it to the program as an argument:
$> ARG="0 8 2 7 3"; ./push_swap $ARG
- The program must return a list of instructions (each followed by a
\n
) that will properly sort the stack in ascending order, something like:
pb
ra
pb
sa
pa
pa
- The bonus part of the project is creating your own checker for push_swap, which will receive as a parameter a stack, and then will wait for the instruction by STDIN.
If, after executing these instructions on the stack, it is properly ordered, the checker must display
OK
. In any other case, it must displayKO
: