Git Product home page Git Product logo

towersofhanoi's Introduction

Towers of Hanoi

A classic CS (and interview) problem where you are asked to move rings of various sizes from the left tower through a middle tower to the rightmost one. The only constraints are you must move only one ring at a time and a ring cannot be moved on top of a smaller ring.

n=4 animation

The instructions for the case where rings = 3 follows:

step left tower middle tower right tower
1. Start 123
2. L -> R 23 1
3. L -> M 3 2 1
4. R -> M 3 12
5. L -> R 12 3
6. M -> L 1 2 3
7. M -> R 1 23
8. L -> R 123

Your task is to generalize this algorithm for the case where rings = n, a positive integer. Assume 3 towers.

towersofhanoi's People

Contributors

mluby avatar yilenpan avatar

Watchers

James Cloos avatar  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.