GithubHelp home page GithubHelp logo

push_swap's Introduction

push_swap

Description

push_swap is a project from the 42 cursus that involves creating a program to sort a stack of integers using a limited set of operations. The main objective is to understand and implement various sorting algorithms and to optimize them for performance and efficiency within the constraints of the project.

Table of Contents

Requirements

To compile and run the project, you will need:

  • A Unix operating system (Linux or macOS).
  • gcc or any C compiler.
  • Make.

Installation

Clone the project repository and navigate to the main directory:

git clone https://github.com/PaLucena/push_swap.git
cd push_swap

Compile the project using the included Makefile:

make

This will generate the push_swap executable in the current directory.

Usage

To sort a stack of integers, run the following command:

./push_swap <list_of_integers>

Where <list_of_integers> is a list of space-separated integers.

Example:

./push_swap 3 2 5 1 4

Operations

The push_swap program supports the following operations to sort the stack:

  • sa: Swap the first two elements at the top of stack A.
  • sb: Swap the first two elements at the top of stack B.
  • ss: Swap the first two elements at the top of both stacks A and B.
  • pa: Push the top element of stack B onto stack A.
  • pb: Push the top element of stack A onto stack B.
  • ra: Rotate stack A upwards (first element becomes the last one).
  • rb: Rotate stack B upwards (first element becomes the last one).
  • rr: Rotate both stacks A and B upwards.
  • rra: Reverse rotate stack A (last element becomes the first one).
  • rrb: Reverse rotate stack B (last element becomes the first one).
  • rrr: Reverse rotate both stacks A and B.

Project Structure

The project is organized into the following files and directories:

  • src/: Contains the source code of the sorting algorithms and operations.
  • include/: Contains the header files.
  • Makefile: Build script to generate the executable.
  • README.md: Project documentation.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

push_swap's People

Contributors

palucena avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.