Tool/Solver to generate moves for The Tower of Hanoi game, a kind of puzzle-game using increasing size stacked discs that the player need to move following some rules.
Hanoï Tower Solver - dCode
Tag(s) : Board Games
dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!
A suggestion ? a feedback ? a bug ? an idea ? Write to dCode!
The tower of Hanoi (or the towers of Hanoi or the problem of the Benares temple, or the towers of Brahma) is the name given to a puzzle-type brain game made up of discs of increasing diameters to form a tower.
This game is often used in mathematics and algorithms to illustrate concepts of recursion and optimization.
The game consists of a round of 7 discs stacked in decreasing size (the largest at the bottom) along a starting vertical axis (source).
The goal is to move these 7 disks on a second axis (destination) via a third following two rules:
— Only move one disc at a time
— Never put disk on a disk smaller than it
The smallest of the 🖸 disks is noted 1, 2 the next one and so on.
The 3 ⟘ posts/pillars are noted from 1 to 3.
Each move consists of changing the position of the n disk from the source pillar to the destination pillar.
Example: '🖸1: ⟘2 → ⟘3' consists of moving the 1 disk located on pillar 2 to pillar 3.
The optimal solution for moving n disks is to perform 2^n-1 moves.
Example: For n=3 disks, the optimal solution involves 2^3-1 = 8-1 = 7 moves.
Play Hanoï tower online here: here
The Tower of Hanoi was invented by French mathematician Édouard Lucas in 1883.
The legend of the Towers of Hanoi (or Towers of Brahma) tells that in the heart of a sacred temple, somewhere in Asia (often associated with Hanoi, Vietnam, sometimes with Benares/Varanasi in India), monks perform an ancient ritual involving three posts and 64 disks (made of gold or sometimes glass). These disks, all of different sizes, are stacked on the first post in perfect order, from the largest at the bottom to the smallest at the top.
The monks are tasked with transferring all the disks from the first post to the third, respecting the rules of the game: move only one disk at a time, never placing a larger disk on top of a smaller disk. According to the legend, as soon as the monks have completed this sacred task, the entire universe will disappear in a final breath.
The legend adds a mystical side to this mathematical game: with 64 disks, it would take billions of years to complete the task following the optimal movement rule (2^64-1 movements at least, or 1.8 × 10^19 in scientific notation, or several billion billion movements, even at a rate of 1 movement per second, it would take several hundred billion years).
dCode retains ownership of the "Hanoï Tower Solver" source code. Any algorithm for the "Hanoï Tower Solver" algorithm, applet or snippet or script (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or any "Hanoï Tower Solver" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) or any database download or API access for "Hanoï Tower Solver" or any other element are not public (except explicit open source licence like Creative Commons). Same with the download for offline use on PC, mobile, tablet, iPhone or Android app.
Reminder: dCode is an educational and teaching resource, accessible online for free and for everyone.
The content of the page "Hanoï Tower Solver" and its results may be freely copied and reused, including for commercial purposes, provided that dCode.fr is cited as the source.
Exporting the results is free and can be done simply by clicking on the export icons ⤓ (.csv or .txt format) or ⧉ (copy and paste).
To cite dCode.fr on another website, use the link:
In a scientific article or book, the recommended bibliographic citation is: Hanoï Tower Solver on dCode.fr [online website], retrieved on 2025-04-16,