After parsing our arguments and handling all the errors, and handling the cases where we have (0 .. 5) numbers, now the work begins :
We must create a temporary stack
fill it with the numbers that are in stack_a
sort it
replace the elements of stack_a with their index in the sorted stack (temporary)
now our work is to push everything to stack_b with some rules :
first of all we gotta specify a range which we will work with
we check if the top of stack_a is :
we repeat this process until we have no longer an element in stack_a
now we have the elements in stack_b taking a shape of a pyramid with the bigger numbers (smaller elements in stack_a (bcs of our index filling)) are in the middle
now its time to refill the stack_a :
now after the first push to a we will observe that the pyramid is in opposite side
and VOILA here’s the stack_a sorted with the minimum of operations :