1. ## Puzzle

The warden meets with 23 new prisoners when they arrive. He tells them, "You may meet today and plan a strategy. But after today, you will be in isolated cells and will have no communication with one another.
"In the prison is a switch room, which contains two light switches labeled A and B, each of which can be in either the 'on' or the 'off' position. I am not telling you their present positions. The switches are not connected to anything.
"After today, from time to time whenever I feel so inclined, I will 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 one, but only one of the switches. He can't move both but he can't move none either. Then he'll be led back to his cell.
"No one else will enter the switch room until I lead the next prisoner there, and he'll be instructed to do the same thing. I'm going to choose prisoners at random. I may choose the same guy three times in a row, or I may jump around and come back.
"But, given enough time, everyone will eventually visit the switch room as many times as everyone else. At any time anyone of you may declare to me, 'We have all visited the switch room.' and be 100% sure. "If it is true, then you will all be set free. If it is false, and somebody has not yet visited the switch room, you will be fed to the alligators."
What is the strategy they come up with so that they can be free?

2. The only strategy I can think of would be to select 1 of the prisoners to count whenever they go into the switch room and switch A is on and switch it off, switching B if it is already off, and for the other prisoners to turn switch A on if it is off, switching B if it is already on or if they have already turned switch A on before. Once the selected prisoner counts to 22 he may conclude that either they have all visited the switch room or that switch A was on to begin with and 1 prisoner is yet to visit the switch room, which would be very unlikely considering that they would have to of evaded something like 506 random selections, leaving this strategy with a 1011/1012 chance of success (if my calculations are correct). To improve the chances, the prisoner who's counting could wait after reaching 22 for as long as they want, for every time they visit I think there's a 64% (approx) chance that, if there were a prisoner yet to be sent, they would be sent between the counter's visits.

Originally Posted by kens
At any time anyone of you may declare to me, 'We have all visited the switch room.' and be 100% sure.
I'm sure this is nothing, but just in case that this is meant as a trick question; the phrasing of this sentence could imply that the warden is secretly letting the prisoners know that they have already been in the switch room. But I'm almost definitely looking into this too much, LOL!