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

help-circle

  • It works the same way.

    1  |  |
    2  |  |
    3  |  |
    4  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 |  |
    12 |  |
    
    |  |  |
    2  |  |
    3  |  |
    4  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 |  |
    12 |  1
    
    |  |  |
    |  |  |
    3  |  |
    4  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 |  |
    12 2  1
    
    |  |  |
    |  |  |
    3  |  |
    4  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 1  |
    12 2  |
    
    |  |  |
    |  |  |
    |  |  |
    4  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 1  |
    12 2 3
    
    |  |  |
    |  |  |
    1  |  |
    4  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 |  |
    12 2  3
    
    |  |  |
    |  |  |
    1  |  |
    4  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 |  2
    12 |  3
    
    |  |  |
    |  |  |
    |  |  |
    4  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  1
    11 |  2
    12 |  3
    
    |  |  |
    |  |  |
    |  |  |
    |  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  1
    11 |  2
    12 4  3
    
    |  |  |
    |  |  |
    |  |  |
    |  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 1  2
    12 4  3
    
    
    |  |  |
    |  |  |
    |  |  |
    2  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 1  |
    12 4  3
    
    |  |  |
    |  |  |
    1  |  |
    2  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 |  |
    12 4  3
    
    |  |  |
    |  |  |
    1  |  |
    2  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 |  |
    11 3  |
    12 4  |
    
    |  |  |
    |  |  |
    |  |  |
    |  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  |  |
    10 2  |
    11 3  |
    12 4  1
    
    |  |  |
    |  |  |
    |  |  |
    |  |  |
    5  |  |
    6  |  |
    7  |  |
    8  |  |
    9  1  |
    10 2  |
    11 3  |
    12 4  |
    
    |  |  |
    |  |  |
    |  |  |
    |  |  |
    |  |  |
    6  |  |
    7  |  |
    8  |  |
    9  1  |
    10 2  |
    11 3  |
    12 4  5
    

    And so on… As you can see, when there was a 3 stack in the right pole, and moved the 4, for the solution to create space for the 5, we move the 3 stack as if it is just a 3 tower and we will end up with a 4 stack tower, allowing us to move the 5 and now we need to move the 4 stack on the 5. As the 4 stack is even, we would start by moving the 1 to the left stack, placing the 2 on the 5 and then the 1 on the 2, creating a 2 stack, now we can move the 3 on the left pole, now we solve the 2 stack, as it is even, we move the 1 to the 4 and the 2 on the 3 and then the 1 on the 2, creating a 3 stack and allowing us to move the 4 onto the 5. Now we solve the 3 stack onto the 4. It is odd, so we solve as we solve the previous 3 tower.

    A bigger tower is just solving a 1 smaller tower basically twice.

    So for solving 12, you solve 11 and move the 12 to the spot, to solve 11 again. To solve 11, you solve 10 and move the 11 and solve 10 again…


  • 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