Skip to content

blueyaGIT/push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

push_swap

Score: WIP/100
Finished: ??.??.2025

push_swap is a sorting algorithm project that sorts a stack of integers with a limited set of operations. The objective is to sort the numbers using the fewest possible moves. This project is part of the 42 School curriculum.

TODO

Usage

To use push_swap, clone the repository in the root of your project using one of the following commands:

SSH

git clone [email protected]:blueyaGIT/push_swap.git

HTTPS

git clone https://github.com/blueyaGIT/push_swap.git

GitHub CLI

gh repo clone blueyaGIT/push_swap

This will create a directory called push_swap/. Enter it with the command:

cd push_swap

Compiling

To compile the program, run:

make

This will generate the push_swap executable.

Running the Program

Execute the program with a list of integers:

./push_swap 4 67 3 87 23

The program will output a sequence of operations to sort the numbers.

Operations

The following operations are used to manipulate the stacks:

  • sa - Swap the first two elements of stack A.
  • sb - Swap the first two elements of stack B.
  • ss - Swap the first two elements of both stacks.
  • pa - Push the top element from stack B to stack A.
  • pb - Push the top element from stack A to stack B.
  • ra - Rotate stack A upwards.
  • rb - Rotate stack B upwards.
  • rr - Rotate both stacks upwards.
  • rra - Reverse rotate stack A.
  • rrb - Reverse rotate stack B.
  • rrr - Reverse rotate both stacks.

Files

  • main.c - Main logic of the program.
  • stack_control*.c - Contains all stack operations.
  • algorithm*.c - Implements sorting algorithms.
  • utils*.c - Utility functions for handling stacks and arguments.
  • push_swap.h - Header file with function prototypes.
  • Makefile - Automates compilation.

Notes

  • The program only accepts integer values.
  • Duplicate numbers are not allowed.
  • The stack is sorted using an efficient combination of operations.

For more details, refer to the project documentation or the 42 subject PDF.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published