Wednesday, February 16, 2011

Towers of Hanoi

Towers of Hanoi is more than a century old mathematical puzzle (1983 to be precise). It consists of 3 rods (pegs), and n disks (n>=1) of different sizes which can slide onto any rod.Lets mark the pegs as S, D & E for Source, Destination and Extra. Initially all the disks are in the S as shown below:

Our task is to move the entire Stack of Disks from Source, S to Destination, D using the extra peg, E. So the final state should be

But, there are some rules of the game to be obeyed:

  1. Only one disk can be moved at a time.
  2. Only the topmost disk can be moved (from any peg).
  3. A bigger disk cannot be placed on the top of a smaller disk ever in the game.
How You will Achieve It??

No comments: