The push_swap project is part of the 42 network curriculum. It is an algorithmic sorting challenge that requires sorting a stack of numbers using only two stacks (stack A and stack B) and a limited set of operations.
- Implements efficient sorting algorithms for small and large sets of numbers.
- Uses a limited number of operations (
sa,sb,ss,pa,pb,ra,rb,rr,rra,rrb,rrr). - Optimizes the number of moves to achieve the best possible solution.
- Handles edge cases such as duplicate numbers and incorrect input formats.
- Designed to work efficiently with different stack sizes.
-
Clone the Repository
git clone https://github.com/haytham-hammioui/42_Push_swap_1337.git push_swap
-
Compile the Program Navigate to the
push_swapdirectory and runmakeandmake bonus. This will generate thepush_swapandcheckerexecutables.cd minitalk make make bonus
-
Run the program
push_swapwith a list of numbers:./push_swap "list of numbers"Example:
./push_swap 4 67 3 87 23
The program outputs a sequence of operations to sort the given numbers.
-
To check if your
push_swapoutput is correct, use the bonuschecker:./checker "list_of_numbers"Example:
./push_swap 4 67 3 87 23 | ./checker 4 67 3 87 23If the sequence correctly sorts the numbers,
checkerwill outputOK, otherwiseKO.
Contributions to push_swap are welcome! Whether you've found a bug, have a feature request, or want to contribute code:
- Fork the repository.
- Create a new branch for your changes.
- Add your contributions.
- Push your branch and open a pull request against the
push_swaprepository.