This project will make you sort data on a stack, with a limited set of instructions, using the lowest possible number of actions. To succeed you’ll have to manipulate various types of algorithms and choose the most appropriate solution (out of many) for an optimized data sorting.
Push_Swap-42School.mp4
Video of program execution on YouTube: https://youtu.be/CugSe5HDVrg
git clone https://github.com/magnitopic/push_swap.git
cd push_swap
git submodule init
git submodule update
make
./push_swap 3 2 1
./push_swap 3 2 1 | wc -l
time ./push_swap 3 2 1
The bonus part of the project is to develop a checker program for the mandatory part. This program will receive the numbers and the instructions from the standard input and will check if the numbers are sorted.
make bonus
./push_swap 3 2 1 | ./checker 3 2 1
You can run Push_swap in this online visualizer.
Execute the program with the numbers the page generates and place the output in a file. You can later upload it and see the execution of the program.
./push_swap 3 2 5 4 1 > result