Push Swap is a program that sorts a stack of integer numbers using two stacks and a set of allowed operations.
To compile the program, run the following command:
make
To run the program, execute the following command:
./push_swap [integer list]
where [integer list] is a list of integer numbers separated by spaces.
The program will output a list of instructions that will sort the integer list.
The following operations are allowed:
- sa : swap the first two elements of stack A
- sb : swap the first two elements of stack B
- ss : sa and sb at the same time
- pa : take the first element from stack B and put it at the top of stack A
- pb : take the first element from stack A and put it at the top of stack B
- ra : shift up all elements of stack A by 1. The first element becomes the last one.
- rb : shift up all elements of stack B by 1. The first element becomes the last one.
- rr : ra and rb at the same time.
- rra : shift down all elements of stack A by 1. The last element becomes the first one.
- rrb : shift down all elements of stack B by 1. The last element becomes the first one.
- rrr : rra and rrb at the same time.