This program, Moves_Tracker
, is designed to track and display the moves made during the execution of a pushswap
sorting algorithm. It shows a step-by-step visualization of stack operations like push
, swap
, and rotate
, helping to debug and visualize the sorting process.
- Tracks and displays the state of the stacks at each step.
- Visualizes the move being executed.
- Handles common
pushswap
operations, such as:pa
(push to stack A)pb
(push to stack B)sa
(swap top two elements of stack A)sb
(swap top two elements of stack B)ra
(rotate stack A)rb
(rotate stack B)rra
(reverse rotate stack A)rrb
(reverse rotate stack B)rrr
(reverse rotate both stacks)
-
Clone the repository to your local machine:
git clone https://github.com/iaceene/Push_Swap_Moves_Tracker.git
-
Navigate into the project directory:
cd Push_Swap_Moves_Tracker
-
Compile the program:
make
Ensure you have a C compiler (e.g.,
gcc
) andmake
installed on your system.
To run the program, use the following command format:
./Moves_Tracker <numbers...>
./Moves_Tracker 3 2 57 44
This command will initialize the stacks with the numbers 3, 2, 57, 44
and perform a series of operations, displaying the results at each step.
------Start-----
3|
2|
57|
44|
- -
a b
-------End-------
pb
------Start-----
2| 3|
57|
44|
- -
a b
-------End-------
pa
------Start-----
3|
2|
57|
44|
- -
a b
-------End-------
sa
------Start-----
2|
3|
57|
44|
- -
a b
-------End-------
ra
------Start-----
3|
57|
44|
2|
- -
a b
-------End-------
rrr
------Start-----
2|
3|
57|
44|
- -
a b
-------End-------
rra
------Start-----
44|
2|
3|
57|
- -
a b
-------End-------
pb
------Start-----
2| 44|
3|
57|
- -
a b
-------End-------
pb
------Start-----
3| 2|
57| 44|
- -
a b
-------End-------
pb
------Start-----
57| 3|
| 2|
| 44|
- -
a b
-------End-------
sb
------Start-----
57| 2|
| 3|
| 44|
- -
a b
-------End-------
rrb
------Start-----
57| 44|
| 2|
| 3|
- -
a b
-------End-------
KO
The program will continue until the final sorting state is reached, displaying the corresponding stack state and move name.
If the program is executed incorrectly, such as with an incorrect number of arguments, it will display an error message:
Error: Incorrect number of arguments.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the contributors and the pushswap community for the original algorithm.
- This tool was created to help visualize the steps of the pushswap algorithm more easily.
Feel free to fork the repository, create an issue, or submit a pull request if you want to contribute improvements, bug fixes, or new features.