Bite 3.5.17 · Modelling Challenges

Tower of Hanoi, the dance of minimum movement

3 rods, a few disks to move a tower

Image by BehindTheTmuna · Unsplash

The Tower of Hanoi is one of the most iconic mathematical and computational puzzles in history. It was invented in 1883 by the French mathematician Édouard Lucas, who accompanied it with a mythical lore: the Legend of the Temple of Benares.

According to the story, the priests of the temple guard three diamond needles with 64 golden disks of varying sizes. Their task is to transfer the entire tower from the first needle to the third following strict, unalterable sacred rules. It is said that when the last move is completed, the temple will crumble and the end of the world will arrive.

Behind this mystical narrative lies a fascinating mathematical structure based on recursion, state combinatorics, and exponential growth.

Formal problem description

The game consists of 3 vertical rods (labeled A, B, and C) and a set of $n$ disks of decreasing diameters initially stacked on rod A (source), ordered from largest at the base to smallest at the top.

The goal is to transfer the entire stack of disks from the source rod A to the destination rod C, abiding by the following rules:

  1. Only one disk can be moved at a time.
  2. A move consists of taking the top disk from one of the rods and placing it on top of another rod or on an empty rod.
  3. No disk may ever be placed on top of a smaller disk.

To analyze the properties of this game, we will focus on the case of $n = 3$ disks:

Do you know what is the minimum number of moves required to complete the game with 3 disks and how to perform the perfect sequence?


The Tower of Hanoi can also be modeled using a binary optimization formulation. Do you dare to try modeling it?

Keep following the series

← Previous · 3.5.16Murdoku Modelling Challenges Next · 4.1.1 →Uniform Search Algorithm

How to cite

Cite this post

Martín-Campo, F. Javier (2026). Tower of Hanoi, the dance of minimum movement. https://www.fjmartincampo.com/blog/2026/towerhanoi/

As a BibTeX entry:

@misc{martín-campo2026tower-of-hanoi-the-dance-of-minimum-movement,
  title   = {Tower of Hanoi, the dance of minimum movement},
  author  = {Martín-Campo, F. Javier},
  year    = {2026},
  month   = {sep},
  url     = {https://www.fjmartincampo.com/blog/2026/towerhanoi/}
}

This post is published under a CC BY-NC-SA 4.0 license.