You are one of ten clever people about to be locked in a strange prison controlled by a computer. You will each be sent to individual isolated cells with no possibility of communication. Randomly, one cell door will open and the prisoner will be allowed access to a central room that contains two on-off switches, a keyboard and a screen showing the exit code. Each door has the same probability of opening. You can assume that both switches are off to start with.

A prisoner has two choices. If they enter the exit code on the keyboard they will be allowed out of prison, but the screen will then go blank. Doors will continue to open, but only those prisoners who can remember the exit code from a previous visit will be able to escape. If they flip either one of the switches they will then be allowed back to the cell they came from and the door will close again. Flipping more than one switch or any attempt to communicate with other prisoners will cause the computer to shut down, and lock all prisoners in forever.

Your challenge is to devise a strategy whereby all prisoners can escape. This means that all prisoners must have visited the room before the first one enters the exit code, and that they can communicate only by setting and observing the switches and the screen.

Solution over the fold.


Call the switches A and B; you are to execute strategy 1; all other prisoners execute strategy 2.

Strategy 1.

  1. If switch A is on, switch it off.
  2. If you have now flipped switch A 9 times, type in the exit code (on screen) and escape.
  3. Otherwise flip switch B.

Strategy 2.

  1. If the screen is blank, type in the exit code (remembered from previous visit) and escape.
  2. Otherwise if this is the first time you have seen switch A off, switch it on.
  3. Otherwise flip switch B.

This method lets you count as each of the other prisoners visits the room for the first time and remembers the code, allowing them to escape later. You defer your escape until they have all visited the room. A blank screen is the signal for each of them to make their escape.