Code Monkey home page Code Monkey logo

pushswap's Introduction

pushswap

Epitech Project, pushswap

Subject:

The game is made up of two lists of numbers named l_a and l_b. In the beginning, l_b will be empty and l_a will contain a certain amount of positive or negative numbers. The objective of the game is to sort l_a.

In order to accomplish this, you will only have access to the following operation: • sa

swap the first two elements of l_a (nothing will happen if there aren’t enough elements). • sb

swap the first two elements of l_b (nothing will happen if there aren’t enough elements). • sc

sa and sb at the same time. • pa take the first element from l_b and move it to the first position on the l_a list (nothing will happen if l_b is empty).

• pb take the first element from l_a and move it to the first position on the l_b list (nothing will happen if l_a is empty).

• ra rotate l_a toward the beginning, the first element will become the last.

• rb rotate l_b toward the beginning, the first element will become the last.

• rr ra and rb at the same time.

• rra rotate l_a toward the end, the last element will become the first.

• rrb rotate l_b toward the end, the last element will become the first.

• rrr rra and rrb at the same time.

You must create a program in which l_a is given as parameter (all numbers are valid and can fit in an integer). The goal is to sort the list by using the fewest possible operations. The program must print the series of operations that enable this list to be sorted.

Example:

alt text

pushswap's People

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

lucasmidy

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.