Prisoners and Switches
A prison warden meets with 23 new prisoners when they arrive. He tells them, "You may meet today and plan your strategy for the challenge I'm about to propose. But after today, you'll be in isolated cells and will have no communication with one another. In the prison is a switch room, which contains two switches labeled A and B, each of which can be in either the On or Off position. The switches aren't connected to anything. I'm not telling you the switches' present positions. After today, from time to time, whenever I feel so inclined, I'll select one prisoner at random and escort him to the switch room. This prisoner will select one of the two switches and reverse its position. He must move only one of the switches. He can't move both switches, and he can't move neither switch. Then, I'll lead the prisoner back to his cell. No one else will enter the switch room until I lead the next prisoner there, and I'll instruct him to do the same thing. I'm going to choose prisoners at random. I might choose the same prisoner three times in a row, or I might jump around and come back. However, given enough time, everyone will eventually visit the switch room as many times as everyone else. At any time, if you're 100 percent certain, any one of you can declare to me, 'We have now all visited the switch room.' If that person is correct, I'll set you all free. If that person is wrong, and somebody hasn't yet visited the switch room, I'll feed you all to the alligators."
What strategy can the prisoners use to obtain freedom?