Skip to content

Sort stacks of numbers in the most efficient way possible

Notifications You must be signed in to change notification settings

magnitopic/push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Push Swap

This project will make you sort data on a stack, with a limited set of instructions, using the lowest possible number of actions. To succeed you’ll have to manipulate various types of algorithms and choose the most appropriate solution (out of many) for an optimized data sorting.

Push_Swap-42School.mp4

Video of program execution on YouTube: https://youtu.be/CugSe5HDVrg

Program

Initial installation

git clone https://github.com/magnitopic/push_swap.git
cd push_swap
git submodule init
git submodule update

Compilation and execution

make
./push_swap 3 2 1

Count amount of moves

./push_swap 3 2 1 | wc -l

Counting execution time

time ./push_swap 3 2 1

Checker program

The bonus part of the project is to develop a checker program for the mandatory part. This program will receive the numbers and the instructions from the standard input and will check if the numbers are sorted.

make bonus
./push_swap 3 2 1 | ./checker 3 2 1

Online visualizer

You can run Push_swap in this online visualizer.

Execute the program with the numbers the page generates and place the output in a file. You can later upload it and see the execution of the program.

./push_swap 3 2 5 4 1 > result