116. Names in Boxes
The names of 100 prisoners are placed in 100 wooden boxes, one name to a box, and the boxes are
lined up on a table in a room. One by one, the prisoners are led into the room; each may look
in at most 50 boxes, but must leave the room exactly as he found it and is permitted no further
communication with the others.
The prisoners have a chance to plot their strategy in advance, and they are going to need it,
because unless every single prisoner finds his own name all will subsequently be executed.
Find a strategy for them which which has probability of success exceeding 30%.
Submitted by tartle · Added 29 August 2016
Solution:
The prisoners can use a strategy based on the numbers associated with their names. Each prisoner starts by opening the box with their own number. If they find their name, they succeed; if not, they take the number found in that box and open the box with that number. They repeat this process for up to 50 boxes. This strategy leverages the structure of permutations, forming chains of boxes that lead back to the starting box. If the chain is shorter than 50 boxes, the prisoner will find their name within the limit. The probability of success, based on the random arrangement of names in the boxes, is approximately 31.8%, as no chains exceed 50 boxes in length.
Comments (1)
Step 1. form a way to order the boxes. Potentially, for example, have the box closest to the door be labeled 1, the next closest 2, etc.
Step 2. sort by names alphabetically, and assign each name a corresponding number
Step 3. As each prisoner walks into the room, go to the box that would correspond with his number - which corresponds to his name. Open the box. read the name inside, recall what number is associated with that name, go to the box associated with that number. Repeat.
Following this path, there is a chain of boxes that would eventually lead back to the box he started at. If he were to return to his starting box, it will be because he found a box containing a name that has a number corresponding to the box he started at. But - big but - his name was the one that corresponded to the box he started at. So if the chain brings him back to his starting box, he must've found the box with his name. If that chain is shorter than 50 boxes, he will have found the box with his name within his 50 box limit. These chains are random, and if names are placed randomly in the 100 boxes, there is a 31% chance that no chains are longer than 50, and everybody survives.
As for proof of that number - each box has a 1/(100 - #boxes in chain so far) probability of leading back to the original box. over fifty boxes in a chain, the overall probability becomes 31.8% for each chain.
Add a Comment or Suggest an Answer