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
a
andb
. - At the beginning,
b
is empty anda
contains a certain number of integers positives or negatives (without duplicates). - The goal is to sort
a
in 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
)sa
andsb
at the same time. - (
pa
) pusha
- Take the first element from top ofb
and put it ona
. - (
pb
) pushb
- Take the first element from top ofa
and 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
)ra
andrb
at 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
)rra
andrrb
at 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;