The Push_swap
project is part of the 42 school curriculum, challenging students to create an algorithm that efficiently sorts a stack of integers using a limited set of instructions. The project includes a bonus section with a checker to verify proper sorting and a visualization of the sorting process.
The project consists of two main parts:
The main push_swap
program implements the sorting algorithm for a stack of integers using a specified set of instructions. The goal is to minimize the number of moves to sort the stack.
The checker
program, located in the bonus
folder, validates whether the stack is correctly sorted after executing a series of commands generated by push_swap.
- Clone the repository:
git clone https://github.com/seungwonme/push_swap.git
- Navigate to the project directory:
cd push_swap
- Compile the push_swap and optionally the checker executable:
make
- To compile the bonus checker:
make bonus
- Run the push_swap program with a list of integers:
./push_swap 5 2 1 4 3
- Check if the stack is sorted using the checker program:
ARG="5 2 1 4 3"; ./push_swap $ARG | ./checker $ARG
- To clean up object files:
make clean
- To delete all build files:
make fclean
- To clean and rebuild the executables:
make re
To visualize the sorting process, visit the Push_swap Visualizer website.