Project in 42 School.
Main goal of this project is to sort numbers using 2 stacks and specific operations.
There are two programs
- Push Swap - takes integer numbers in arguments and generates operations to sort them using two stacks named 'a', 'b' respectively. At the start all integers passed as arguments is written in stack 'a'.
- Checker - takes commands generated by push_swap into stdin, numbers to apply this operations on in arguments, and checks if this commands will sort this numbers. If yes - displays OK, if no - displays KO. In case of error - displays Error.
git clone --recurse-submodules https://github.com/oevtushe/push_swap.git && cd push_swap && make
- pa - push from 'a' to 'b'
- pb - push from 'b' to 'a'
- sa - swap top 2 elements in 'a'
- sb - swap top 2 elements in 'b'
- ss - swap top 2 elements in both stacks
- ra - rotates stack 'a' (the first element becomes the last one)
- rb - rotates stack 'b'
- rr - rotates both stacks
- rra - reverse rotates stack 'a' (the last element becomes the first one)
- rrb - reverse rotates stack 'b'
- rrr - reverse rotates both stacks
-c - colored printing both stacks, you can see
what is going on with stacks after every
command executed.
-d - execute commands in the real time, you
type the command, checker execute it and
prints the stacks.
-fd <filename> - force checker to read commands from
file except stdin.
--pretty='<pretty string>' - changes the view of stacks,
run ./checker --pretty='' to see format.
-s - prints statistics of operations executed (sum of all operations executed,
and number of executions for each operation)
-fd <filename> - writes commands in file.
1. ARG='<random numbers>'; ./push_swap $ARG | ./checker $ARG
2. ARG='<random numbers>'; ./push_swap $ARG | ./checker -c $ARG
3. ARG='<random numbers>'; ./push_swap $ARG | ./checker -s $ARG
4. ARG='<random numbers>'; ./push_swap $ARG | ./checker --pretty='^_^:: ^ ' $ARG