meritissimo1 / push_swap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

push_swap

image

This program that takes a list of ints as arguments:

$ ./push_swap 7 1 8 9 4 2 6 5 3 (Bottom)

Put them into stack a:

Then sorts them with stack b and using the operations:

  • 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

  • pa: (push a): Take the first element at the top of b and put it at the top of a

  • pb: (push b): Take the first element at the top of a and put it at the top of b

  • ra: (rotate a): The first element becomes the last one

  • rb: (rotate b): The first element becomes the last one

  • rr: ra and rb at the same time

  • rra: (reverse rotate a): The last element becomes the first one

  • rrb: (reverse rotate b): The last element becomes the first one

  • rrr: rra and rrb at the same time

stack a must be sorted from smallest to largest

I enjoyed the project and learned a lot about Data Structure, doubly linked lists, circular linked list and sorting algorithms :D

About


Languages

Language:C 97.6%Language:Makefile 2.4%