Skip to content

Sorting algorithm using two stacks and a limited set of operations. Developed as part of the 42 school curriculum.

License

Notifications You must be signed in to change notification settings

GinaldoFT/push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

push_swap cover

🧮 push_swap

push_swap is a sorting algorithm project from the 42 curriculum.
It consists in writing a program that sorts a stack of integers using a limited set of operations and the smallest number of moves possible.

push_swap badge


🎯 Project Objective

The goal of push_swap is to sort a list of integers with the lowest number of operations, using only two stacks (A and B) and a predefined set of instructions (like sa, pb, rra, etc.).

You will:

  • Implement a sorting algorithm optimized for minimal operations
  • Use data structures such as linked lists
  • Optimize performance for different input sizes (up to 500 numbers)
  • Write a checker to validate the correctness of instructions

⚙️ Allowed Instructions

Instruction Description
sa swap the first two elements of A
sb swap the first two elements of B
ss sa and sb at the same time
pa push the top of B onto A
pb push the top of A onto B
ra rotate A (first becomes last)
rb rotate B
rr ra and rb at the same time
rra reverse rotate A
rrb reverse rotate B
rrr rra and rrb at the same time

About

Sorting algorithm using two stacks and a limited set of operations. Developed as part of the 42 school curriculum.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published