Skip to content

Push_swap is a project that involves sorting a stack of numbers using a set of instructions. The project is written in C and can be compiled with a Makefile.

License

Notifications You must be signed in to change notification settings

yel-hadd/push-swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

push-swap

Push_swap is a project that involves sorting a stack of numbers using a set of instructions. The project is written in C and can be compiled with a Makefile.

Preview

preview.mov

Allowed Instructions

  • sa : swap the first two elements at the top of stack a.
  • sb : swap the first two elements at the top of stack b.
  • ss : sa and sb at the same time.
  • pa : take the first element at the top of b and put it at the top of a.
  • pb : take the first element at the top of a and put it at the top of b.
  • ra : rotate a - shift up all elements of stack a by 1. The last element becomes the first one.
  • rb : rotate b - shift up all elements of stack b by 1. The last element becomes the first one.
  • rr : ra and rb at the same time.
  • rra : reverse rotate a - shift down all elements of stack a by 1. The first element becomes the last one.
  • rrb : reverse rotate b - shift down all elements of stack b by 1. The first element becomes the last one.
  • rrr : rra and rrb at the same time.

Usage

To use push_swap, clone the repository and compile it with the following commands:

$ git clone https://github.com/yel-hadd/push-swap
$ cd push-swap
$ make

Then, you can sort a stack of numbers by running the following command:

$ ./push_swap [numbers]

where [numbers] is a list of numbers to be sorted.

Output

The program outputs the series of instructions required to sort the stack.

About

Push_swap is a project that involves sorting a stack of numbers using a set of instructions. The project is written in C and can be compiled with a Makefile.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published