This project aims to sort a stack
A of integers, using an other stack B
and the following set of operations :
sa
swaps two integers at the top ofstack A
pa
takes the first element at the top ofstack B
and put it at the top ofstack A
ra
takes the top element ofstack A
and put it at its bottomrra
takes the bottom element ofstack A
and put it at its top
There are analog operations for stack B
, i.e sb
, pb
, rb
and rrb
.
Plus operations to perform on both stacks :
ss
performssa
andsb
rr
performsra
andrb
rrr
performsrra
andrrb
In the root folder run make
, it will produce two executables push_swap and checker.
push_swap expects a list of distinct integers as arguments, it will represent stack A
, then ouput the list of operations it performed to sort the stack.
checker expects a list of distinct integers as argumentsm it will respresent stack A
, and read a list of operations on stdin
, then check if these operations successfully sorted stack A
.