Skip to content

hanmpark/push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

push_swap

A sorting algorithm project focusing on efficiency and instruction minimization.


Repository created at Repository code size Mostly used language

📖 Description

The push_swap project challenges you to sort a stack of integers using two stacks (a and b) and a set of restricted operations.

The goal is to sort the stack with the fewest possible instructions, introducing concepts of algorithmic complexity, optimization, and data structure manipulation.

You’ll need to implement both the sorting algorithm and the official instructions, then optimize your solution for efficiency.

🛠️ Features

🔨 Push_swap Instructions

Instruction Description
sa Swap the first 2 elements of stack a.
sb Swap the first 2 elements of stack b.
ss sa and sb simultaneously.
pa Push the top element of b onto a.
pb Push the top element of a onto b.
ra Rotate stack a (first element becomes last).
rb Rotate stack b (first element becomes last).
rr ra and rb simultaneously.
rra Reverse rotate stack a (last element becomes first).
rrb Reverse rotate stack b (last element becomes first).
rrr rra and rrb simultaneously.

📦 Installation

Clone the repository and compile:

git clone https://github.com/hanmpark/push_swap.git
cd push_swap
make

🚀 Usage

Run the program with a list of integers:

./push_swap 2 3 1 4

For the bonus checker:

make bonus
./checker "2 3 1 4"

📊 Grading Scale

Number of integers Points Instruction limit
3 Pass required <= 3
5 Pass required <= 12
100 1 → ≤ 1500 2 → ≤ 1300
500 1 → ≤ 11500 2 → ≤ 10000

👤 Authors

About

Sorting a pile of data in ascending order

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published