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.
root@a5df87da6a06:/project# ARG='4 8 2 11 -7 -6'; ./push_swap $ARG
ra
ra
pb
ra
pb
pb
rrb
pa
pa
pa
ra
ra
ra
pb
pb
pb
pa
pa
pa
ra
ra
ra
- Clone the project.
git clone [email protected]:ricardoreves/42-push-swap.git
- Navigate to the project directory.
cd 42-push-swap
- Compile the push_swap.
make
- Run push_swap
# single argument
./push_swap "4 0 1 3 2"
# multiple arguments
./push_swap 4 0 1 3 2
- Run instructions checker
ARG='4 0 1 3 2'; ./push_swap $ARG | ./checker $ARG
- Install python
brew install python3
- install python
sudp apt update
sudo apt install python3 python3-pip python3-venv
- Make a virtualenv
# create an environnement
python3 -m venv .env
# activate env
source ./.env/bin/activate
- Install dependancies
pip install -r requirements.txt
- Run average tester
make test
- With 3 numbers, we need to sort it with not more than 3 instructions.
- With 5 numbers, we need to sort it with not more than 12 instructions.
- With 100 numbers, we can get
5 points if the size of the list of instructions is less than 700
4 points if the size of the list of instructions is less than 900
3 points if the size of the list of instructions is less than 1100
2 points if the size of the list of instructions is less than 1300
1 points if the size of the list of instructions is less than 1500
- With 500 numbers, we can get
5 points if the size of the list of instructions is less than 5500
4 points if the size of the list of instructions is less than 7000
3 points if the size of the list of instructions is less than 8500
2 points if the size of the list of instructions is less than 10000
1 points if the size of the list of instructions is less than 11500
- Run visualizer
make viz
- PushSwapVisualizer - This is a python GUI app that helps visualize how the 42 project
push_swap
project works. - PushSwapTester - This tester shows the performance of your push_swap program.
- medium.com - Introduction to the
push_swap
project. - medium.com - The least amount of moves with two stacks.
- geeksforgeeks.org - How to calculate a median.
- commentcamarche.net - Liste doublement chaînée.
Distributed under the MIT License. See LICENSE for more information.