Git Product home page Git Product logo

pin3dev / 42_push_swap Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 7.33 MB

Algorithm challenge focused on sorting a stack of integers with the minimum number of operations. Implemented in C with a limited set of operations, ideal for understanding algorithm optimization.

License: MIT License

C 94.15% Makefile 5.85%
algorithm c 42cursus 42porto 42pushswap 42school tutorial tutorial-sourcecode sorting sorting-algorithm sorting-algorithms

42_push_swap's Introduction

Push Swap 100/100

🎰---TUTORIAL---🎰

Table of Contents

Overview

The push_swap project is an algorithm challenge aiming to sort a stack of integers using the least possible number of operations, adhering to a specified set of allowed operations.

This repository does not have a checker, so it is necessary for the sorting test to be carried out by third-party testers or by the checker provided by 42.

Features

  1. Efficient algorithm to sort the stack.
  2. Limited set of operations: sa, sb, ss, pa, pb, ra, rb, rr, rra, rrb, rrr.

Compilation and Execution

#Compilation
make

#Execution option 1:
ARG="3 5 2 1 4"; ./push_swap $ARG
#[...list of operations...]

#Execution option 2:
./push_swap 3 5 2 1 4
#[...list of operations...]

Usage Examples

#Test counting the amount of movements:
ARG="3 5 2 1 4"; ./push_swap $ARG | wc -l
#[...amount of operations...]

#Test counting the amount of movements:
./push_swap 3 5 2 1 4 | wc -l
#[...amount of operations...]

#Test with sort checker:
ARG="3 5 2 1 4"; ./push_swap $ARG | ./checker $ARG
#OK

#Test with non-integer:
./push_swap 3 5 2 one 4
#Error

./push_swap 3 5 2 -2147483649 4
#Error

./push_swap 3 5 2 2147483649 4
#Error

./push_swap 3 5 2 --2 4
#Error

./push_swap 3 5 2 -+2 4
#Error

./push_swap 3 5 2 - 4
#Error

Contributors

42_push_swap's People

Contributors

pin3dev 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.