Skip to content

Contents of 42sp's Seventh Project - Sort a Stack of Integers Using Only a Set of Specific Moves

Notifications You must be signed in to change notification settings

ArthurSobreira/42_push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Push Swap [125 / 100]

Summary

The seventh project in the 42sp fundamentals track, Push Swap, is based on the creation of a program that receives as parameter a stack (ordered or not) and sorts it by ascending order, using only a set of specific movements (SA, SB, SS, PA, PB, RA, RB, RR, RRA, RRB, RRR). The main objective of this project is to introduce the concept of complexity and sorting algorithms.


Run the Program

  • Make sure you clone the repository with the following command:
$> git clone [email protected]:ArthurSobreira/42_push_swap.git
  • Once cloned, to compile the program, use the following commands:
$> make / make bonus

Mandatory Part

  • To run the mandatory part of the program, you just need to have access to a stack, and pass it to the program as an argument:
$> ARG="0 8 2 7 3"; ./push_swap $ARG
  • The program must return a list of instructions (each followed by a \n) that will properly sort the stack in ascending order, something like:
pb
ra
pb
sa
pa
pa

Bonus Part

  • The bonus part of the project is creating your own checker for push_swap, which will receive as a parameter a stack, and then will wait for the instruction by STDIN. If, after executing these instructions on the stack, it is properly ordered, the checker must display OK. In any other case, it must display KO:

About

Contents of 42sp's Seventh Project - Sort a Stack of Integers Using Only a Set of Specific Moves

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published