This is a attempt to solve the push_swap project of 42 school. The sorting algorithm is based on Merge sort.
READ THE DISCLAIMER!
This code is **NOT** a valid solution for the project.
This is just an attempt.
This is a merge sort working on 2 stacks.
This code is in a WIP-state.
This code is partly very hard to read because i couldn't make it work good enough for the projects requirements.
For 100 random numbers this algorithm needs roughly 1400-1600 actions. Requirement is less than 1300 actions.
For 500 random numbers this algorithm needs roughly 10500 actions. Requirement is less than 11500 actions.
If you want to see the satisfying sorting run it with a visualizer:
I always used this visualizer.
The checker that you can see in my files, is the cecker suppliedd by 42.
There will be quite some errors in the code, caused by the lack of testing it enough.
The Code you might find inside the Libft-folder, is awfull, since alot of the functions are still from the first time i started coding.
But the main algorithm works mostly.
Since i didn't finish the project, the Makefile still WIP.
Compile with:
gcc *.c actions/*.c libft/*.c -o push_swap
Run it with:
./push_swap 3 5 20 17 19 9 15 12 13 11 7 16 10 14 18 2 1 8 4 6
Or if you have the visualizer i used:
python3 pyviz.py `ruby -e "puts (1..20).to_a.shuffle.join(' ')"`
This is an example of my code working with 50 numbers.