The Hanoi coins game

Logic Level 5

Suppose you are given 4 pairs of coins of different diameters and you have in front of you drawn 3 squares S 1 S_1 , S 2 S_2 , S 3 S_3 on a piece of paper anyway.

In the first two squares , S 1 S_1 and S 2 S_2 , you construct 2 towers of 4 coins where each coin is placed on a coin with a bigger diameter.

All coins in tower A are up , all coins in tower B are down. You play a game such that starting from this you must invert it , all coins in A should be down and all coins in B should be up by a sequence of moves which has anyway the following rules.

Anyway , consider a move to respect the following 2 characteristics:

  1. At every moment of a "move" you take the above coin of one of the towers and move it in one of the 2 other squares available anyway.
  2. Of course , you are not allowed to move a coin over another coin which has a smaller diameter anyway.

What is the minimum number of moves necessary for you to swap the 2 towers of coins ?

Insert your number as that number of minimum moves necessary.


And , for having a bonus (which almost necessary imposes itself) can you find a general understanding of what is the smallest number of moves necessary to made for any equal number of coins placed in the two towers at the beginning of the game anyway ?


The answer is 59.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Matt Janko
May 15, 2020

As the coins accumulate, they naturally form "double towers," or towers with layers of two coins of equal radius. We know from the traditional tower of Hanoi game that the minimum number of moves to transfer a tower with n n coins of different radii is 2 n 1 2^n - 1 , so the minimum number of moves to transfer a double tower with 2 n 2n coins is 2 ( 2 n 1 ) 2(2^n - 1) . With this understanding, we can find a recurrence relation that gives the minimum number of moves to construct a double tower with 2 n 2n coins. To swap towers, we construct a double tower on S 3 S_3 and then deconstruct it in mirror reverse order (i.e., by replacing moves to or from S 1 S_1 with moves from or to S 2 S_2 and performing the moves in reverse).

Suppose A A and B B have n n coins each, and label the coins in increasing order of radius a 1 , , a n , b 1 , , b n a_1, \dots, a_n, b_1, \dots, b_n . Let u n u_n and v n v_n denote the minimum number of moves to combine A A and B B into a double tower of 2 n 2n coins on S 2 S_2 and S 3 S_3 , respectively, and let w n w_n denote the minimum number of moves to swap A A and B B . To combine A A and B B on S 2 S_2 , we must

  • construct a double tower with 2 n 2 2n - 2 coins on S 3 S_3 ,
  • move a n a_n on top of b n b_n , and then
  • transfer the double tower on top of b n b_n and a n a_n .

The minimum number of moves for this process is u n = v n 1 + 1 + 2 ( 2 n 1 1 ) . u_n = v_{n - 1} + 1 + 2(2^{n - 1} - 1). To combine A A and B B on S 3 S_3 , we can

  • construct a double tower with 2 n 2 2n - 2 coins on top of b n b_n on S 2 S_2 ,
  • move a n a_n from S 1 S_1 to S 3 S_3 ,
  • transfer the double tower from S 2 S_2 to S 1 S_1 ,
  • move b n b_n on top of a n a_n on S 3 S_3 , and then
  • transfer the double tower from S 1 S_1 to S 3 S_3 .

We also could have started by constructing the double tower on a n a_n , but that would not have changed the minimum number of moves, which is v n = u n 1 + 1 + 2 ( 2 n 1 1 ) + 1 + 2 ( 2 n 1 1 ) . v_n = u_{n - 1} + 1 + 2(2^{n - 1} - 1) + 1 + 2(2^{n - 1} - 1). To swap A A and B B , we can

  • construct a double tower with 2 n 2n coins on top of b n b_n on S 2 S_2 ,
  • move a n a_n to S 3 S_3 , and then
  • transfer the double tower on to a n a_n on S 3 S_3 .

Again, we could have started by building the double tower on top of a n a_n , but that would not change the minimum number of moves for these steps, which is u n + 1 + 2 ( 2 n 1 ) . u_n + 1 + 2(2^n - 1). Whatever sequence of moves we use for the three steps above, we can move b n b_n to S 1 S_1 and then apply the mirror reverse sequence to reconstruct the towers in swapped positions. The minimum number of moves to swap the towers is then w n = 2 [ u n 1 + 1 + 2 ( 2 n 1 1 ) ] + 1. w_n = 2[u_{n - 1} + 1 + 2(2^{n - 1} - 1)] + 1. From these recurrence relations and the initial conditions u 1 = 1 u_1 = 1 , v 1 = 2 v_1 = 2 , and w 1 = 3 w_1 = 3 , we can compute u n u_n , v n v_n , and w n w_n for all n n . The first few values are given in the following table.

n n u n u_n v n v_n w n w_n
1 1 2 3
2 5 7 9
3 14 29 25
3 34 44 59

When n = 4 n = 4 , the minimum number of moves to swap the towers is w 4 = 59 w_4 = \boxed{59} .

2 pending reports

Vote up reports you agree with

×

Problem Loading...

Note Loading...

Set Loading...