23 prisoners and two switches


A prison has 23 prisoners in 23 different cells. The prisoners have no way to communicate with each other in any way from their cells. There is another room, the rec room, that has two switches on the wall (A and B). The switches have on and off positions but they start in an unknown position.

Prisoners are randomly taken to and from the rec room one at a time. They must change the position of only one of the two switches each time they go to the room. At any point a prisoner can yell out, “Every prisoner has been here!” If the prisoner is correct that all of the prisoners have visited the rec room, then they all go free. If they aren’t correct then they are all executed.

Before they start they are given one planning session during which they can discuss a method to win the game. What method can they use to ensure they all go free?

Add Comment

  • 1 Answer(s)

    Here are the rules they can use to ensure they will all go free eventually:

    The prisoners will choose one ‘leader’ and everybody else will be a follower. If you are a follower:

    • If switch A is in the on position, toggle switch B.
    • If switch A is off, you have not toggled switch A yet, and you have seen switch on during a previous visit; then toggle switch A. Otherwise toggle switch B.

    If you are a leader:

    • If switch A is off, turn it on.
    • If switch A is on, turn it off. If you did not turn switch A on during their previous visit, increment the count of prisoners.

    Once the leader increments the count to 23 they can yell, “Every prisoner has been here!” and all of them will be released.

    silent47 Expert Answered on 21st August 2015.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.
  • More puzzles to try-