Giter Club home page Giter Club logo

push_swap's Introduction

Doc

Algo Push_swap

Concept ⚙️

After many tests and reasearchs it appeared that the best solution to have best results was to put all the numbers in stack B in the good descending order. So the scale to search the good value in A to put in B is the whole A stack. But as we don't want to run the half of the stack to put the right A value to the top of B, we prefer to see on each A value the perfect spot in B and how many moves it takes to drop it off.

We finally choose the combination of A value/B spot which takes the less moves to be achieved.

A to B

While A is not empty, we look for the best move (shortest) to be achieved. We execute this move then search for the next best move. And so on.

B to A

B stack is sorted in a descending way but it doesn't necessarily starts from the highest or smallest value. As we need to have the highest value at the bottom of A and the smallest at the top to get the ascending order we want, we just need to move the highest value of B to its top then push them all. End of game.

push_swap's People

Contributors

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