Giter VIP home page Giter VIP logo

42-push_swap's Introduction

Push Swap

This project sorts the numbers randomly entered into the program from smallest to largest.

I learned a lot of sorting algorithms while doing the project. I developed some of these that are suitable for me and integrated them into my project.


Project Details

It is not enough to use normal sorting algorithms in this project. Because there are certain rules for sorting, for example, you cannot move a number anywhere you want.You can only do these with set rules. You can view the pdf for more details.

This project uses different sorting algorithm according to the number range entered.

  • Sorts for 3 arguments in a maximum of 2 moves.
  • Sorts in less than 12 moves for 5 arguments.
    • Calculates where the 2 smallest numbers are and assigns them to stack B. The remaining ones in stack A work the algorithm I wrote before for the triple argument. When the sorting is complete, the numbers in stack B are sent back to stack A.
  • Only one algorithm works for numbers greater than 5. It makes 6021 moves for 500 arguments (and that's partly a good statistic).
    • Basically this algorithm works on bits. Therefore, it performs a fixed move for arguments of the same size.

Sample Output

Sorted in two moves.

make
./push_swap 3 2 1
ra
sa

42-push_swap's People

Contributors

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