Skip to content

icepick4/tower-of-hanoi

Repository files navigation

tower-of-hanoi

Intro to the game

The Tower of Hanoi (also called The problem of Benares Temple or Tower of Brahma or Lucas' Tower and sometimes pluralized as Towers, or simply pyramid puzzle) is a mathematical game or puzzle consisting of three rods and a number of disks of various diameters, which can slide onto any rod. The puzzle begins with the disks stacked on one rod in order of decreasing size, the smallest at the top, thus approximating a conical shape. The objective of the puzzle is to move the entire stack to the last rod, obeying the following rules:

  • Only one disk may be moved at a time.
  • Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack or on an empty rod.
  • No disk may be placed on top of a disk that is smaller than it. With 3 disks, the puzzle can be solved in 7 moves. The minimal number of moves required to solve a Tower of Hanoi puzzle is 2^(n − 1), where n is the number of disks.

(« Tower of Hanoi » 2022).

Bibliography : Tower of Hanoi. (12th April, 2022). In ​Wikipedia​. https://en.wikipedia.org/wiki/Tower_of_Hanoi

Playing

Two dimensions version

  • Drag & Drop : Drag disks then drop them onto towers to play !
    URL : Drag&Drop

  • Click To Select : Click on a tower to select the disk at the top of it then click on another to play !
    URL : ClickToSelect

Three dimensions version

Made with ThreeJS.

Usage : Click on a disk to pick it, then click on a tower to place it.

URL : ThreeJS

Dev

Clone the projet, then

npm i
npm run dev

Care, if you want to work on a precise project, you have to change paths in server.js and webpack.config.js.