Winkler described the following puzzle, titled "Names in Boxes," in his paper "Seven Puzzles You Think You Must Not Have Heard Correctly."

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. They may look into up to 50 of the boxes to try to find their own name, but must leave the room exactly as it was.

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. They may look into up to 50 of the boxes to try to find their own name, but must leave the room exactly as it was.

The prisoners are permitted no further communication after leaving the room. They do have a chance to plot a strategy in advance. Good thing. Unless they all find their own names, they will all be executed.

If each prisoner examines 50 boxes at random, the probability of the group's survival is a minuscule 1/2

^{100}. Even worse, if they all happen to look into the same 50 boxes, their chances drop to zero.
However, there is a strategy that the prisoners can use to increase the probability of success to more than 30 percent. Incredible but true! The trick is to find this strategy.

This puzzle, in a different form, was originally devised by computer scientist Peter Bro Miltersen. It appeared in a 2003 paper on substring searches presented at a conference on automata, languages, and programming and later published in a journal.

Here's the strategy.

Beforehand, the prisoners randomly assign "ownership" of one box to each prisoner. As a result, each of the 100 boxes now has a "label" on the outside.

Each prisoner goes to the box with his name on it. He finds another prisoner's name in the box. He then looks into the box labeled with that prisoner's name. He continues in this fashion until he finds his own name or ends up looking into 50 boxes.

Why does this procedure greatly increase the prisoners' chances of survival?

The random assignment of a box with a name in it to each prisoner is just a permutation of the 100 names, chosen uniformly at random from the set of all such permutations, Winkler explained.

So, in inspecting boxes, each prisoner follows a cycle of that permutation, beginning with his box. If they don't exceed the 50-box limit, they succeed in finding their own name. If the particular permutation chosen by the prisoners happens to have no cycle of length greater than 50, the process works, every prisoner finds his name, and no one gets executed.

Indeed, the probability that a random permutation of 2

*n*objects has no cycle of length greater than*n*is at least 1 minus the natural logarithm of 2.
In this case, the probability of the prisoners surviving is a bit larger than 1 –

*ln*2. It comes to 31.18 percent.
The strategy works because the prisoners, in effect, impose a structure on their search and take advantage of a basic property of random permutations.

## No comments:

Post a Comment