Chain Link 2
Previous puzzle in this series
An apprentice is working for you, the village’s master blacksmith, for 21 days. For payment, you have agreed to give him a gold chain with 21 links, one link for each day. However, you both don’t trust each other: you don’t want to pay him the entire length of the chain, only for him to not show up. Likewise, he doesn’t want to work for you for 21 days, only to find out that he wouldn’t get paid. You come to an agreement: you’ll give him a chain link after each day of work.
You can split the chain by cutting a link open, separating the chain, then welding it back. To minimise the damage to the chain (and the work you have to do), you want to minimise the number of cuts made to the chain. What’s the minimum number of chain links you need to cut to allow this transaction?
Day 1: you give the apprentice the chain of length 1
Day 2: the apprentice returns the chain of length 1, and you give him a chain of length 2
Day 3: you give the apprentice the chain of length 1
How can we extend this to 21 days?
Hint
if the chain link is of length 3, we can make 1 cut to create two chains of length 1 and 2 links respectively. You can perform the following transactions each day:
Hint
if you have a chain of 6 links, you can cut the 3rd link in order to make 3 chains of length 2, 3, and 1 (the cut link).
Solution
We can do this with 4 cuts. First, cut the 5th, 12th, and 21st link. When welding the links shut, combine 2 of the cut links into a chain of length 2. This leaves us with chains of length 1, 2, 4, 6, and 8.
Day 1: You pay with the chain of length 1.
Day 2: The apprentice returns the previous day’s chain and you give him the chain of length 2.
Day 3: You pay with the chain of length 1, giving him 3 links in total.
Day 4: The apprentice returns the previous chains and you give him the chain of length 4.
In fact, as long as you can use these chains to represent all lengths from 1 to 21, you can make your apprentice all previous chains and pay him the exact amount. The representations are as follows:
| Day | Breakdown |
|---|---|
| 1 | 1 |
| 2 | 2 |
| 3 | 2+1 |
| 4 | 4 |
| 5 | 4+1 |
| 6 | 4+2 |
| 7 | 4+2+1 |
| 8 | 8 |
| 9 | 8+1 |
| 10 | 8+2 |
| 11 | 8+2+1 |
| 12 | 8+4 |
| 13 | 8+4+1 |
| 14 | 8+4+2 |
| 15 | 8+4+2+1 |
| 16 | 6+8+2 |
| 17 | 6+8+2+1 |
| 18 | 6+8+4 |
| 19 | 6+8+4+1 |
| 20 | 6+8+4+2 |
| 21 | 6+8+4+2+1 |
To see how this works, a good starting point would be to look at binary representations of numbers. As a refresher, the binary representation of a number indicates how it can be represented as a sum of unique powers of two. For example, 45=32+8+4+1. If we have chains of length 32, 8, 4, and 1, then we can make a full payment of 45. By extension, if we have chains of length 1, 2, 4, 8, 16, and 32, we can represent all the numbers 0 to 63 (all 6-digit binary numbers). In general, if we have k chains in ascending powers of 2 (1, 2, 4, … 2k−1), you can represent all the numbers from 0 to 2k−1.
Unlike the previous puzzle, 21 is 6 more than 15. As earlier mentioned, we can represent all the numbers from 0 to 15 with 4 chains of length 1, 2, 4, and 8. To be conservative, the remaining 6 chain links can be on a single chain. For payments of more than 15 chains, we pay with the chain of length 6, then pay the remainder with the original method (since it will now be within the 0-15 range). That leaves us with 5 chains of length 1, 2, 4, 6, and 8 respectively. We can do this by cutting 4 chain links to produce 5 shorter chains.
Can we do better than 4 cuts? Yes! Notice that if we’re given a chain of length 6 and we cut the 3rd link. From a single cut, we can get 3 pieces of chain of length 2, 3, and 1 (the link we cut).
We still want to split the chain to get shorter chains of length 4, 6, and 8, so let’s cut them at the 5th, 12th, and 21st links. When re-welding the links, we can link 2 of the links to form a 2-length chain, giving us the 5 chains we need.
Try These Next
Chomp 2
After winning the previous game, your friend is back for revenge. This time, he has a chocolate bar made of n by n squares. The same rules apply: You will take...
Guessing Hats 3
The king’s challenges are growing crueller. This time, three wise men stand in a room, each wearing either a black or white hat chosen at random by a coin...
Covering a Chessboard 1
You’re given an 8x8 chessboard with 2 opposite corner tiles removed. You can place dominoes on the board, with each one covering exactly 2 adjacent tiles (you...