Sunday, February 23, 2014

Hanoi Tower

In the first assignment of the term, we were introduced to a game called Hanoi Tower. This mathematical puzzle consists of three rods and different sizes of disks that can be moved onto any rod. Some rules apply to the game, that bigger disks can not be stack onto smaller ones. To win the game, someone has to move all the disks from the original rod to a destination rod within the least moves. The tricky part was that we had to deal with the more complex version.
Four rods were given, and we were required to find the most efficient solution on this task. Me and my partners followed the steps provided. None of us foresaw the difficulty of this assignment until step four which we had to write recursions for the solution. We suddenly realized that within four rods, the whole game changed.
Instead of three rods, using four rods gives us one more intermediate rod which makes the case more complicated. The strategy of playing this game is to choose a number between one and the number of total disks (call it n) in the game, call it i. We first move i disks onto either one the intermediate rods by using all four rods here. Then we move n-i disks onto the final destination rods using three rods that are available. Last, we move i disks onto destination rods using four rods. After a few rounds of moving, we realized that we could play the game by using recursion. Recall that recursion is a method that to run a function which contains this function itself. Here in this case, we have to use three recursion one after another. First, we use a recursive function of moving disks within four rods, then a recursive function of moving disks within three rods, and lastly another recursive function of moving disks within four rods.
The key to find the least moves is the choice of i. We discovered that within 10 disks, we chose i to be the middle number of the total n. However, when the disks increase to more than 10, we failed to find the most efficient way of solving the problem.

No comments:

Post a Comment