This project is about sorting a list composed of integer values while being restricted in the possibles moves.
Rules:
- The game is constituted of two piles named
aandb. - At the beginning,
bis empty andacontains a certain number of integers positives or negatives (without duplicates). - The goal is to sort
ain an increasing way. - To this end we dispose of the following operations:
- (
sa) swapa- Swap the first two elements ofa. - (
sb) swapb- Swap the first two elements ofb. - (
ss)saandsbat the same time. - (
pa) pusha- Take the first element from top ofband put it ona. - (
pb) pushb- Take the first element from top ofaand put it onb. - (
ra) rotatea- Shift of a position all elements ofa(towards the top, the first element becomes the last). - (
rb) rotateb- Shift of a position all elements ofb(towards the top, the first element becomes the last). - (
rr)raandrbat the same time. - (
rra) reverse rotatea(towards the bottom, the last element becomes the first). - (
rrb) reverse rotateb(towards the bottom, the last element becomes the first). - (
rrr)rraandrrbat the same time.
- (
Installation:
git clone git@github.com:Aaramis/push_swap.git;
make;
make bonus;Generate integer list using ruby:
sudo apt-get install ruby;
ARG=$(ruby -e puts "(1..100).to_a.shuffle.join(' '))";Execution:
./push_swap $ARG > test;
./checker $ARG < test;