Skip to content

gerus66/push-swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

104 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Push-Swap

Task

full version in pdf
There are two 'stacks' (not in the general meaning of this terms) - A is filled with unique numbers and B is empty.
Given a list of permitted instructions, A should be sorted in ascending order with the minimum number of instructions possible.

Full list of instructions to manipulate with 'stacks':
sa sb ss - swap the first 2 elements at the top of A / B / both at once
pa pb - take the first element at the top of B (or A) and push it to the top of A (or B)
ra rb rr rotate all elements of A / B / both at once , the first element becomes the last one
rra rrb rrr reverse rotate all elements of A / B / both at once, the last element becomes the first one

Run

macos:
make & ARG=$(python3 gen.py N); ./push_swap $ARG | ./checker [-g|-v|-c] $ARG

in case of problems with the miniLibX graphic library, binary could be compiled without it:
make no-graph & ARG=$(python3 gen.py N); ./push_swap $ARG | ./checker [-v|-c] $ARG

linux: in progress

Utils

gen.py N returns array of N uniqie numbers in range [-N, N]

push_swap A returns sequence of instructions sorting the given array A

checker [-g|-v|-c] A reads instructions from the standart input (one at a time) and consequentially applies them to A.
   -v print A and B to the standart output
   -c last move is highlighted (use it with -v)
   -g graphic mode with animation (doesn't work with make no-graph compilation)
          control keys: left/right for speed control, space for pause, esc.

./checker -g

Alt text

./checker -v -c

Alt text

Codestyle

Developed in strict accordance with Norminette codestyle
Based on selfmade libft library

About

Sorting stacks under specific conditions - algorithmic project at Ecole 42

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors