Source: Alok Goyal (Stellaris VP) puzzle blog

Problem:

This is another famous puzzle in the Martin Gardner collection, and variations of this puzzle exist in different “sizes”. This particular one has been picked up from The Colossal Book of Short Puzzles and Problems, Puzzle 9.18. Replicating the puzzle as is.

The traveler soon realizes that this can be accomplished by cutting the chain in many different ways. The problem is: What is the smallest number of links the traveler needs to cut to carry out his agreement for the full 23 days?

1. Minimum links - 5. Length of each link - 1, 2, 4, 8, 8

2. You only need to cut 2 links. Specifically, if the links are numbered 1,2,...,23, then cut the links numbered 4 and 11. This gives you three chains of lengths 3, 6, and 12, plus the two broken links. This is optimal, since cutting a single link does not suffice.

Here's how this works.

Day 1: give her a broken link.
Day 2: give her the second broken link.
Day 3: give her the 3 chain, and take back the broken links as change.
Days 4-5: repeat days 1 and 2.
Day 6: give her the 6 chain, taking back the 3 chain and two broken links as change.
Days 7-11: repeat days 1-5
Day 12: give her the 12 chain, take back all previous pieces as change.
Days 13-23: repeat days 1-11.

1. Didn't really understand how you are breaking the chain. How are you getting "two broken links"?

2. There are two cuts, each of which passes through a single link. Before the cut, the link will look the letter O. After the cut, it looks like the letter C. The adjacent links can now be passed through the broken one.

3. So, even with this case, we are making 4 cuts (not 2 as you wrote). Hence, both the options below require exactly 4 cuts

option-1) 1,2,4,8,8
option-2) 1,1,3,6,12

3. This comment has been removed by the author.

4. I wrote sort of an evolutionary algorithm to explore more possibilities. Basically you cannot get there using 4 links since 4 digits in binary representation only get you up to 15. But 5 digits get you to 31, and that leaves some room for 23.
[1,2,3,5,12]
[1,1,3,6,12]
[1,2,4,7,9]
[1,2,2,6,12]
[1,2,4,5,11]
[1,2,3,7,10]
[1,2,4,8,8]
[1,2,3,6,11]
[1,2,4,4,12]
[1,2,4,6,10]

1. Can you share the code for the same ?

2. I think I have deleted the file already. But here's the rough idea: each 'solution' is represented by a list of numbers adding up to 23. There is a function testing whether it is a legal solution, by exhausting all possible subset of this list and see if they add up to every possible number between 1 and 23. Then there is another function which exhausts all possible ways of picking two numbers and merge them into one (or intuitively, cutting the link into 23 separate pieces is a trivial solution, we are looking to see how to merge the links and get longer ones). After each proposed merge you test whether the solution is still legal and you give up the merge step if it isn't. Repeat this enough times and you will see a lot of solutions.

3. I somehow stumbled upon the code I wrote years ago so here they are:

5. according to the question, how many links needed to be cut?
Its 4 as when we cut 4 links at 1,2,4 & 8 intervals from the begining we have finally 5 small chains of 1, 2, 4, 8 & 8 links in them but cut made is only 4 (i.e 4 individual links are cut down).

6. 4 cuts need to be made, of lenght 1,2,4,8 and the last peice whic will remian will be of 8 link. So he can pay for all 23 days.
1 - 1
2 - 2
3 - 1+2
4 - 4
5 - 1+4
6 - 4+2
7 - 4+1+2
8 - 8
9 - 8+1
10 - 8+2 .. and so on

7. The blog description says that this blog contains both questions and the answers. Where are the answers?

8. Doesn't seem like anyone has proved that 4 cuts (or 5 pieces) is the minimum that can be achieved (although the proof isn't that hard). Suppose that it is possible to get all numbers from 1 to 23 with just four pieces. That means we get an encoding of all 23 numbers with just 4 bits (each piece corresponds to a bit and it's 0 or 1 depending on whether you give that piece to the landlady or not), which is a contradiction.