This project has been created as part of the 42 curriculum by smoustaj.
the goal of push_swap is to sort a list of unique numbers using the smallest possible number of steps.
we only have two tools (stacks):
- stack A: starts with the unsorted numbers.
- stack B: starts empty and is used as temporary storage.
this program uses the RADIX Sort algorithm with a least significant bit (LSB) strategy. Instead of sorting the large original numbers, we first assign each number a simple rank (index). The program then sorts the stack by looking at the binary digits (bits) of these ranks, moving elements back and forth between Stack A and Stack B until Stack A is perfectly sorted.
Use the provided Makefile to compile the executable:
make
example :
# option 1: multiple arguments
./push_swap 10 2 1 3 4
# option 2: quoted string
./push_swap "10 2 1 3 4"
usage with the checker:
./push_swap 5 4 3 2 1 | ./checker 5 4 3 2 1
# expected output on success: OKdidn't use any.