anolivei / Push_swap42

Because Swap_push isn’t as natural xD

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Push_swap

Because Swap_push isn’t as natural

Github top language Github language count Repository size Norminette

About   |   Links   |   Functions   |   Starting   |   Testing   |   Author


About

  • Push_swap is an algorithm project at school 42 and the instructions were given in the subject.
  • We start with two stacks called A and B.
  • A is filled with some random integers (without duplicates) and B is empty.
  • We can perform a limited set of instructions on these stacks and the goal is to sort all these integers using the lowest possible number of actions.
  • The limited set of instructions are:
Operation Description
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 - 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

Links

Functions

Only the following functions are allowed to be used in this project:

  • write
  • read
  • malloc
  • free
  • exit

Starting

# Clone this project
$ git clone https://github.com/anolivei/Push_swap42

# Access
$ cd Push_swap42

# Compile the program
$ make

# Run the project
$ ./push_swap 5 8 7 2

Testing

obs: you must use bash terminal

# on linux OS
ARG="4 67 3 87 23"; ./push_swap $ARG | ./checker_linux $ARG

# on Mac OS
ARG="4 67 3 87 23"; ./push_swap $ARG | ./checker_Mac $ARG

# lfrasson tester
bash lfrasson_tester.sh

# push_swap visualizer
python3 python_visualizer.py `ruby -e "puts (-50..50).to_a.shuffle.join(' ')"`

  Back to top

About

Because Swap_push isn’t as natural xD


Languages

Language:C 80.8%Language:Python 9.1%Language:Shell 6.0%Language:Makefile 4.1%