Welcome to the push_swap project! 🚀 This project is a challenge from 42 School that involves sorting a stack of numbers using a limited set of operations. The goal is to create an algorithm that sorts numbers with the minimum number of operations possible. 🧠💡
push_swap is a sorting algorithm project where the objective is to sort a stack of integers in ascending order. You have to implement a sorting algorithm using only a set of predefined operations. The challenge is to achieve the sorting with the fewest number of operations.
sa- Swap the top two elements of stack Asb- Swap the top two elements of stack Bss- Swap the top two elements of both stacks A and Bpa- Push the top element of stack B to stack Apb- Push the top element of stack A to stack Bra- Rotate stack A up (top element becomes the last one)rb- Rotate stack B up (top element becomes the last one)rr- Rotate both stacks A and B uprra- Reverse rotate stack A down (last element becomes the top one)rrb- Reverse rotate stack B down (last element becomes the top one)rrr- Reverse rotate both stacks A and B down
-
Clone the Repository 🔄:
git clone https://github.com/yourusername/push_swap.git cd push_swap -
Compile the Code ⚙️:
make all -
Run the Program 🚀:
./push_swap [numbers] -
BONUS (Checker) ✅:
cd checker make all ARG=[numbers] ../push_swap/push_swap $ARG | ./my_checker $ARG
The checker is used to verify if the stack has been correctly sorted by your push_swap implementation.
- If the stack is sorted correctly,
checkerwill outputOK. ✅ - If the stack is not sorted correctly,
checkerwill outputKO. ❌