Thanks to visit codestin.com
Credit goes to github.com

Skip to content

appinha/42cursus-02-push_swap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

42cursus' push_swap

Development repo for 42cursus' push_swap project
For further information about 42cursus and its projects, please refer to 42cursus repo.

GitHub code size in bytes Number of lines of code Code language count GitHub top language GitHub last commit


🗣️ About

This project will make you sort data on a stack, with a limited set of instructions, using the lowest possible number of actions. To succeed you’ll have to manipulate various types of algorithms and choose the one (of many) most appropriate solution for an optimized data sorting.

For detailed information, refer to the subject of this project.

🚀 TLDR: this project consists of coding a program that finds the lowest possible number of moves to
sort a random list of integers using 2 stacks and a limited set of operations

📑 Index

@root

  • 📁 includes: contains the program's headers.
  • 📁 libft: contains the source code of the libft library, which is used in the program.
  • 📁 srcs: contains the source code of the program.
  • Makefile - contains instructions for compiling the program and testing it.

Note: only mandatory requirements of the project's subject are covered.

🛠️ Usage

Requirements

The program is written in C language for Linux distributions and thus needs the clang compiler and some standard C libraries to run.

Instructions

1. Compiling the program

To compile the program, run:

$ make

2. Executing the program

To execute the program, run:

$ ./push_swap $ARG

where $ARG is a space separated list of integers, e.g. ARG="1 5 2 4 3"

📋 Testing

(to be written)

📌 Useful Links

🤓 Study Summary

Actions

PUSH

Take the first element at the top of one stack and put it at the top of the other; do nothing if the origin stack is empty.

  • pa - top element of stack b goes to top of stack a.
  • pb - top element of stack a goes to top of stack b.

SWAP

Swap the first 2 elements at the top of the stack; do nothing if there is only one or no elements.

  • sa - swap stack a.
  • sb - swap stack b.
  • ss - sa and sb at the same time.

ROTATE

Shift up all elements of the stack by one; the first element becomes the last.

  • ra - rotate stack a.
  • rb - rotate stack b.
  • rr - ra and rb at the same time.

REVERSE ROTATE

Shift down all elements of the stack by one; the last element becomes the first.

  • rra - reverse rotate stack a.
  • rrb - reverse rotate stack b.
  • rrr - rra and rrb at the same time.

About

Development repo for 42cursus' push_swap project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published