simongalasso / push_swap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

push_swap

A program that can check if a stack is sorted, and also sorting it if it is not,
There is two stacks and rules to move numbers : ra, rb, sa, sb etc...

Built with

C language

Installing

  • Git clone the repository
  • Compile it with make

Make it work

  • Run ./checker [list of numbers] and write a combination of move to check if you sorted it
  • Run ./push_swap [list of numbers] to get the right combination of move

Rules

sa : swap 2 first element of pile a
sb : swap 2 first element of pile b
ss : do sa and sb
pa : push first element of pile b to pile a
pb : push first element of pile a to pile b
ra : rotate to the top all element of pile a
rb : rotate to the top all element of pile b
rr : do ra and rb
rra : rotate down all element of pile a
rrb : rotate down all element of pile b
rrr : do rra and rrb

Example

> ./checker 3 2 1
> rra
> sa

Author

Simon Galasso

About


Languages

Language:C 96.0%Language:Makefile 4.0%