Push_swap (42cursus) 2021
Actual Status : Finished
Result : 125%
Push_swap is a 42 Project, the goal of which is to sort the stack using a limited set of operations and as few instructions as possible. It is allowed to use only two stacks (Stack A and Stack B), as a result of the program, stack A must be sorted in ascending order from top to bottom.
There are only a few moves that are allowed to be used, let's call them "actions" :
$>./push_swap 2 1 3 6 5 8
sa
pb
pb
pb
sa
pa
pa
pa
The actions are called: sa, sb, ss, pa, pb, ra, rb, rr and rra, rrb, rrr.
This program reads the instructions passed to push_swap and checks whether the stack is sorted.
$>./checker 11 9 5 3
rra
pb
sa
rra
pa
OK
Run make bonus
to compile the checker program.
Run ./push_swap 6 9 1 | ./checker 6 9 1
(or ARG="4 67 3 87 23"; ./push_swap $ARG | ./checker $ARG
). The program should display OK if the instructions are correct. If the stack is still not sorted, the program will display KO. If you submit duplicated numbers, arguments that are not numeric or int, the program will return Error. The argument must be the same for checker and push_swap.
Need help: emaksimo@student.42yerevan.am
Special thanks: elijahkash for the push_swap_gui