A program that can check if a stack is sorted, and also sorting it if it is not,
There is two stacks and rules to move numbers : ra, rb, sa, sb etc...
C language
- Git clone the repository
- Compile it with
make
- Run
./checker [list of numbers]
and write a combination of move to check if you sorted it - Run
./push_swap [list of numbers]
to get the right combination of move
sa : swap 2 first element of pile a
sb : swap 2 first element of pile b
ss : do sa and sb
pa : push first element of pile b to pile a
pb : push first element of pile a to pile b
ra : rotate to the top all element of pile a
rb : rotate to the top all element of pile b
rr : do ra and rb
rra : rotate down all element of pile a
rrb : rotate down all element of pile b
rrr : do rra and rrb
> ./checker 3 2 1
> rra
> sa
Simon Galasso