Skip to content

moop250/push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

push_swap

Description

push_swap is a 42 project that challenges students to create an efficient sorting algorithm to sort a stack of numbers with a limited set of operations. The aim is to sort the stack using the least number of moves possible. This project implements the "Turk algorithm," a strategic approach to solving the problem as discussed in this article. The algorithm works by calculating which move will take the least amount of moves to get the lists closer to being sorted.

Base Features

  • Sort a stack of integers using two stacks and a limited set of operations.
  • Check for errors and handle non-integer and duplicate inputs.
  • Print the list of operations needed to sort the stack.

Bonus Functionality

The bonus part of push_swap introduces additional features:

  • Checker Program: A separate program that checks if the stack is sorted after applying the operations given by push_swap.

Compatibility & Size

Usage

To clone the repository use:

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

Compilation & cleanup:

  • make : Compiles the push_swap program.
  • make bonus : Compiles the checker program.
  • make all : Compiles both the push_swap and checker programs.
  • make clean : Cleans up object files (.o).
  • make fclean : Cleans up all files generated by running make, including executables.
  • make re : Performs a make fclean followed by a make all to recompile the programs.

Example usage of push_swap:

ARG="4 67 3 87 23"; ./push_swap $ARG

Example usage with checker bonus:

ARG="4 67 3 87 23"; ./push_swap $ARG | ./checker $ARG

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors