Thursday, September 30, 2010

010 - Prisoners and Switches

Twenty-three prisoners are imprisoned in an unusual prison. They are to be imprisoned until the warden of the prison decides to set them free.

The warden meets the prisoners as they arrive and tells them about a special room in the prison. In the room are two switches, each of which can be set either an "up" position or a "down" position. The switches are not connected to anything, and the warden does not tell the prisoners whether either switch is currently "up" or "down".

"I am about to give you an hour to plan, talking amongst yourselves," says the warden to the prisoners. "After that, you will be incarcerated in separate cells with absolutely no means of communication."

"From time to time during your imprisonment, I will select one of you at random and escort that prisoner to the switch room. The prisoner I select must select one, and only one, of the two switches and reverse its position. Then he will be led back to his cell. This is the only way in which the switches will be flipped; they will always be in the position that the last prisoner to visit the room left them in."

"The method by which I select a prisoner will be totally random and it may result in the same prisoner being selected several times in a row."

"At any time that a prisoner is in the switch room, he or she may announce to me, 'We have all visited the switch room.' If that prisoner is correct, you will all be set free. If they are incorrect, you will all be executed in a particularly painful manner."

What is the fastest way for the prisoners to win their freedom, without the slightest risk of being executed?