Skip to content

meritissimo1/push_swap

Repository files navigation

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

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published