Towers of Hanoi

By Omar Essilfie-Quaye

Github Repo Link to github repository Docs Link to source code documentation

The Priests of Brahma

Legend says that at the beginning of the universe in the Kashi Vishwanath temple, devoted to Lord Shiva, that a room was created with three posts. These posts were home to 64 golden disks that were to be moved from the first post to the last post according to the rules of a divine prophecy. The priests are allowed to make but one move a day and it is rumoured that when the puzzle is completed the world would end.

The towers of Hanoi puzzle, also known as the towers of Brahma, is a mathematical puzzle created in 1883 by French mathematician Édouard Lucas. François Édouard Anatole Lucas is also known for his study of the famous mathematical sequence known as the Fibonnaci sequence and the related Lucas sequence is named after him.

The Rules

The goal of the puzzle is to move the entire stack of plates from one rod to another whilst obeying the simple rules shown below. There are some variants of this puzzle which have popped up over the years where the rules have been slightly altered. One example is the Magnetic towers of Hanoi. In this variant each plate has two sides a north and a south and plate sides which are similar may not touch, additionally plates must be flipped as they are moved.

  • 1) Only one disk can be moved at a time.
  • 2)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.
  • 3) No larger disk may be placed on top of a smaller disk.