• 0 Posts
  • 4 Comments
Joined 2 years ago
cake
Cake day: June 30th, 2023

help-circle
  • Hey for anyone who doesn’t know how to solve tower of Hanoi, there is a simple algorithm.

    1. |. |
    2. |. |
    3. |. |

    Let’s say, we want to move the center rod.

    Count the stack of disks that you need to move: e.g. 3

    If it is even, start with placing the first disk on the spot that you don’t want to move the tower to. If it is odd, start with placing the first disk on the spot that you want to move the tower to.

    
    |.   |.   |
    2.  |.   |
    3.  1.  |
    
    |.   |.    |
    |.   |.    |
    3.  1.  2
    
    
    |.   |.   |
    |.   |.   1
    3.  |.   2
    
    
    |.   |.   |
    |.   |.   1
    |.   3.  2
    

    Now the 2 stack is basically a new Hanoi tower.

    That tower is even and we start with placing the first disk on the spot that we don’t want to land on

    
    |.   |.   |
    |.   |.   |
    1.  3.  2
    
    
    |.   |.   |
    |.   2.  |
    1.  3.  |
    
    |.   1.  |
    |.   2.  |
    |.   3.  |
    

    And we solved the tower. It is that easy