Prisoners and permutations
2006.08.19
Mathematics

A neat little puzzle (and its solution) at ScienceNewsOnline.

The scenario is this:

The names of 100 prisoners are placed in 100 wooden boxes, one name per box (assume the are all named differently). The boxes are lined up on a table in a room. Prisoners would be allowed in one by one. Each may look at the contents of 50 of the boxes, but they cannot rearrange the boxes, change the contents, i.e. they have the leave the room the way the found it. The entrance and exit of the room are separated, so prisoners who have looked cannot communicate with prisoners who haven't looked.

The king decrees the following: if all prisoners find the box with their own names, they would be free. Otherwise they'd be executed. They are given a chance to talk this through in advance before the first prisoner is led into the room.
Now, if each of the prisoners look at the boxes randomly, he/she would have a 50% chance of seeing a name. The probability of the group's survival becomes 0.5100, an impossibly small number.

But, there is one strategy that could lead to a chance of survival greater than 30%. How?

From the article, here's what the prisoners could do. Assign to each prisoner a unique number from 1 to 100. When a prisoner is allowed into the room, he goes first to the box corresponding to his number. He looks at the name inside. He next looks for the box corresponding to the number of the person whose name is inside the box, and so on until he finds his own name or exhausts his 50 boxes.

How does this increase the chance of survival?

Let's look at this diagramatically. Since the names of the prisoners are unique, we can instead imagine that they are called by the number they assigned each other. And thus in each of the 100 boxes is a number. For the sake of illustration, we simplify it down to 10 boxes (and 10 people). We can imagine it looking somewhat like this

 Box num: 1 2 3 4 5 6 7 8 9 10 
 Content: 3 6 8 10 9 7 2 4 5 1 
When it is the turn of the prisoner named "1" to go in, he looks first in box 1, then in box 3, then in box 8, then in box 4, then in box 10, and there he finds his number. Prisoner 2 would look in box 2, box 6, and then box 7. Prisoner 3, however, would look in box 3, box 8, box 4, box 10, and then box 1. Hum, doesn't that sequence sound familiar to you? It is the same sequence prisoner 1 went through but in a slightly different order!

What we have here is what mathematicians call a permutation: an assignment to each member of a set another unique member of the set (the assignment is allowed to associate a member to itself). This is what the prisoners have done! The room with the boxes in it can be thought of as function that maps from the ordered set of boxes to the names contained in the boxes. This is obviously a 1-to-1 function. By assigning one box to each of the prisoners, the prisoners constructed another 1-to-1 function, this time from the set of prisoners to the set of boxes. Composing the two we have a map from the set of prisoners to themselves that is 1-to-1, and hence, a permutation.

A permutation admits a cycle-representation. Take the simplified model we have above. Recall that prisoners 1 and 3 ended up with similar, but offseted sequences of boxes. A cycle in a permutation is a sequence through the set that comes back to itself. To illustrate, for the model we constructed, the cycle representation is:

 ( 1 3 8 4 10 ) ( 2 6 7 ) ( 5 9 ) 
The first name that prisoner 1 finds would be that of prisoner 3, and then 8, and then 4, and so on. The cycle wraps back at the boundary, so the first name prisoner 6 finds would be that of prisoner 7, then prisoner 2.

From the illustration, it is easy to see that the cycles partition the set of prisoners into disjoint parts: prisoners 2, 6, and 7 would only see each other's names (and boxes), which prisoners 1, 3, 8, 4, 10 form their own little clique.

With all these preliminaries, we can now explain how the strategy helps.

We can see that the number of boxes that a prisoner has to open corresponds to the number of people in his cycle. In our model, prisoner 1 is in a cycle of length 5, i.e. that in his group there are 5 people. Prisoner 2 has length 3, and so on.

For the prisoners in the original scenario to survive, they have to choose a permutation such that all the cycles have 50 people or fewer. Since they don't originally know which names is in which boxes, their assignment of numbers is a random choice of permutation among all possible permutations. Their probability of survival, thus, is the same as the percentage of all permutations of 100 names that contains no cycles with more than 50 people.

Some small calculations:

So, in the end, the percentage of good permutations is 1 - Σn= 51 .. 1001/n, which, a quick punch in the calculator shows to be roughly 31.183%

(Hum, you ask, where does the article pull the phrase "Indeed, the probability that a random permutation of 2n objects has no cycle of length greater than n is at least 1 minus the natural logarithm of 2" from? That can be derived using the above calculations via Stirling's formula.)

Posted at 14:13:45 EDT by W comment

blogCentralFront Page
2009.07.03 22:41:26 EDT Valentine for the relativity geek This just came randomly into my head (well, while I am trying to think up a T-shirt design). A (really geeky) valentine's day card for your favourite relativity geek: Rμν - ½ R gμν
2009.06.12 11:42:48 EDT Introducing my new blog: Asking Questions After thinking about it for a while, I've decided that I will get a WordPress account. Most of the reasons are given in this post from a few months ago. In any case, this will not mean the death of bl
2009.05.31 00:27:49 EDT A list of Japanese restaurants Mom was on a plane, and sat next to a Japanese ex-pat, so she asked for restaurant recommendations. This is the list: Restaurant RIKI 141 E 45 St. Phone: 212-986-1109 Sakagura 211 E 43 St. B1F. Phone
2009.05.06 16:45:31 EDT Journal: Call me doctor Whoa! I am a PhD* now. I didn't sleep too well last night. I was way too nervous. There was really no reason for me to be though: I do not know (which is different from there doesn't exist) of a case
2009.04.29 19:46:57 EDT Unconventional Derivation of Kerr Metric I've posted one set of lecture notes on an unconventional derivation of the Kerr metric. This is a condensation of the lecture I gave on Apr 23 for MAT 451 in Princeton University.
2009.04.28 11:23:22 EDT Are we putting too much faith in the savior? Hypothetically speaking, would it have been better for President Obama if, instead of the Democratic landslide of 2008, he was elected to face an adversarial congress dominated by Republican majoritie
2009.04.17 18:22:07 EDT Dissertation status: finished! The dissertation is done! Actually I finished it yesterday around 2:30 pm. But I haven't had the chance to blog about it until now. Something about having a late afternoon seminar yesterday, more semi
2009.03.28 17:16:04 EDT A problem in modular arithmetic In an New York Times Magazine article on Freeman Dyson, the following problem is posed: Does there exist a natural number in base 10 where if you move the last digit to the front, e.g. transfrom 12345
2009.03.19 12:02:42 EDT Gowers's experiment and future of blogOhm A remarkable on-line collaboration in mathematics happened recently. Tim Gowers initiated a fairly modest program some 6 weeks ago, trying to get a heuristic justification (or refutation) on how one s
2008.12.16 22:43:46 EST Illustrious company My advisor invited me over for dinner tonight. He wrote the book on nonlinear PDE techniques in the global theory for general relativity. Around the table were also I. M. Sigal, who wrote the book on