Giter Club home page Giter Club logo

push-swap's Introduction

screen shot 2018-09-12 at 10 19 50

Because Swap_push isn’t as natural

Summary: 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.

instructions Description
sa swap first two elements of stack A
sb swap first two elements of stack B
ss sa and sb at the same time
pa pops the first elememt on B and puts it on top of A
pb pops the first elememt on A and puts it on top of B
ra rotates stuck A up by one
rb rotates stuck B up by one
rr rotates both A and B up by one
rra rotates stuck A down by one
rrb rotates stuck B down by one
rrr rotates both A and B down by one

The next 3 images show you the basic process that the algorythm follows to sort the arguments using two stacks. Using the visualiser I wrote as a bonus. can be called using "-v" flag.

screen shot 2018-09-12 at 10 22 30screen shot 2018-09-12 at 10 22 24

The screenshot below shows the visualiser once the stack has been sorted, see the OK which is the checkers output meaning that the push-swap program sorted the arguments screen shot 2018-09-12 at 10 22 14

Finally the "-s" flag shows each stack after every opperation as shown with 3 arguments. In the screenshot below you can see the use of the ARG=`ruby -e "puts (0..3).to_a.shuffle.join(' ')"`; which populates ARG with random numbers which is then passed as the arguments to both the checker and the push-swap programs.

screen shot 2018-09-12 at 10 24 32

-WE THINK CODE(CPT)

push-swap's People

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.