A 42 Cursus Project
The project requires students to receive an unsorted arrangement of numbers and sort them in ascending order with a limited set of instructions.
Instruction | Description |
---|---|
sa (swap a) | swap the first two elements at top of Stack A |
sb (swap b) | swap the first two elements at top of Stack B |
ss | perform sa and sb simultaneously |
pa (push a) | take the first element of Stack B and place in top of Stack A |
do nothing if B is empty | |
pb (push b) | take the first element of Stack A and place in top of Stack B |
do nothing if A is empty | |
ra (rotate a) | move all elements up in Stack A |
rb (rotate b) | move all elements up in Stack B |
rr | perform ra and rb simultaneously |
rra (reverse rotate a) | move all elements down in Stack A |
rrb (reverse rotate b) | move all elements down in Stack B |
rrr | perform rra and rrb simultaneously |
Libft library is allowed in the project.
Sorts 3 numbers in < 3 moves
Sorts 5 numbers in < 12 moves
Sorts 100 numbers in < 900 moves
Sorts 500 numbers in < 8500 moves
good enough
Early 2022 Version of push_swap
Does not include bonuses
https://zainab-dnaya.medium.com/fastest-push-swap-algorithm-2f510028602b
https://medium.com/nerd-for-tech/push-swap-tutorial-fa746e6aba1e