(Tower of Hanoi)

Tower of Hanoi by Spolarium is an adaptation of the math puzzle of the same name.

Gameplay

The gameplay features disks, and 3 pegs. The goals is to get all blocks to the last peg (chequerboarded for convenience) in a pyramid structure from biggest to smallest as fast as possible. Click a peg to dislodge a disk, and click the next peg where you wish to place the disk. Here are the rules:

  • You can only move one disk at a time
  • You take either the only disk on a peg, or the top disk of a stack, and move it onto the top of another stack, or onto an empty peg.
  • You may not place a disk on top of a smaller disk.

Solution

The following is an iterative solution. From left to right, we will call the pegs A, B and C.

For any n disks, the minimum amount of moves to make to solve the puzzle is (2^n)-1.


For an even amount of disks, the following is done:

  • Make a legal move from A to B in any direction.
  • Make a legal move from A to C in any direction.
  • Make a legal move from B to C in any direction.

Repeat this until the puzzle is solved.


For an odd amount of disks, the following is done:

  • Make a legal move from A to C in any direction.
  • Make a legal move from A to B in any direction.
  • Make a legal move from B to C in any direction.

Repeat this until the puzzle is solved.