Skip to content

TheFr34k42/push_swap

Repository files navigation

push_swap

The push swap project all about sorting stack using the action below.

Actions :

  • sa : swap a - Swap the first 2 elements at the top of stack A. Do nothing if there is only one or no elements).
  • sb : swap b - Swap the first 2 elements at the top of stack B. Do nothing if there is only one or no elements).
  • ss : sa and sb at the same time.
  • pa : push a - take the first element at the top of b and put it at the top of a. Do nothing if B is empty.
  • pb : push b - take the first element at the top of a and put it at the top of b. Do nothing if A is empty.
  • 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.

Clone the project with : git clone https://github.com/BleedTheFreak/push_swap.git

after that Use : make as in the img :

drawing

Example :

When program start there is two stacks stackA & stackB the StackA full with program arguments and stackB Empty :

drawing

stackA : [3] [2] [1]
sa :
stackA : [2] [3] [1]
rra :
stackA : [1] [2] [3]
  • Final mark :

    drawing
  • About

    No description, website, or topics provided.

    Resources

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published