The Prisoners' Switch Problems

Version 2

This can be reduced to version 1's solution (almost) if we take switch A to be the “signal” switch let prisoners use switch B if they can't send a signal (because A is already on or because they have already sent their signal.

The problem is, we don't know the initial state of A. If switch A is initially on, Fred will receive a false signal.

The solution to this problem is to go through the process twice. Every prisoner is told to flip switch A twice, the first two times they enter the room and see the signal switch off. In the end, Fred will necessarily see 44 signals (22 other prisoners times 2 signals each). After 44, Fred knows she received 2 signals from everybody, or possibly 2 from 21 of the corresponding prisoners and one from another, but, either way, every prisoner has entered the room. Fred can now say with certainty that everybody has been in the room at least once.