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.11.20 00:41:20 GMT Feynman's Messenger Lectures online Just found out something rather cool: Microsoft Research, through Project Tuva, is publishing videos of Richard Feynman's Messenger Lectures. Go watch.
2009.11.18 11:05:07 GMT Alcohol consumption Different cultures certainly have different views on alcohol. For example, at Hertford College Oxford, wine is allowed if reasonably drunk and 4) A small amount of beer or lager will be allowed wher
2009.11.16 19:17:31 GMT Luc visits; Willie doesn't check e-mail Holy cow! I just realized that I spent a day at work without checking e-mail! Okay, to be honest, today I was hosting Luc Nguyen, who we invited to speak on his work about the regularity near the sing
2009.11.15 18:19:32 GMT Chicken soup Chicken soup is not just good for the soul. It has been scientifically proven to mitigate inflammation. Maybe mommy's chicken soup was the reason that the same bug that took Pin out of commission for
2009.11.10 17:58:53 GMT Sayonara, e-nibbles; hullo, Gee-Mi-Ni It's final: e-nibbles is no more. e-nibbles was my trusty Dell D600 which I purchased summer after my Junior year in college through the Student Computer Initiative. Immediately after receiving the ob
2009.09.30 10:12:57 BST Ahhh! Cruft discovered in pre-print. Ack, I should've known better. I stayed up a bit later on Monday night than I intended to. I was asked, by Claude, last week, about whether certain cases (in particular the Born-Infeld model) not cove
2009.09.28 18:30:27 BST Spiders spiders everywhere Wow! Third post today, and here I thought I have been neglecting my blog. Anyway, it turns out that I am not the only person to have noticed the large number of spiders in Britain this autumn. Going o
2009.09.28 15:12:09 BST Causality of generalized wave-maps--paper on arXiv Oh, almost forgot. New paper on arXiv. Gary Gibbons showed via explicit computations using eigenvalues that the Skyrmion equation obeys the dominant energy condition. In my paper, I proved the dominan
2009.09.28 14:42:39 BST The evolution debate as an illustration of speciation I was reading some article or another in Wired, which happens to be about dinosaurs. And of course, the religious kooks came out of the woodwork to attack evolution on the comment board. And it occurr
2009.09.02 12:42:44 BST New beginnings: first days at Cambridge Heh. Did you, dear reader, notice the change on the date-stamp for the previous entry? It was posted in British Standard Time. Yes, I am now taking a position in the Department of Pure Mathematics and