Skip to content

Files

Latest commit

author
Gedeon RONY
Jan 17, 2022
4c6bd0a · Jan 17, 2022

History

History

push_swap

push_swap

Push_swap is a project about efficiently sorting a list of numbers with some constraints.

We have two stacks and the following commands at our disposal:

  • pb : push b - take the first element at the top of a and put it at the top of b

  • pa : push a - take the first element at the top of b and put it at the top of a

  • sa : swap a - swap the first 2 elements at the top of stack a

  • sb : swap b - swap the first 2 elements at the top of stack b

  • ss : sa and sb at the same time

  • ra : rotate a - shift up all elements of stack a by 1. The first element becomes the last one

  • rb : rotate b - 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 : reverse rotate a - shift down all elements of stack a by 1. The last element becomes the first one

  • rrb : reverse rotate b - shift down all elements of stack b by 1. The last element becomes the first one

  • rrr : rra and rrb at the same time

The project

  • 📶 "push_swap" executable will accept the numbers as arguments and will display the necessary commands to sort them.