100 prisoners & a light bulb puzzle:
- There are 100 prisoners in the prison cells.
- Prisoners cannot communicate with each other by any means.
- There is a light bulb in central living room and initially its off.
- light bulb can be switched on or off.
- light bulb is not visible to any prisoners from their respective cells
- Warden can pick up any prisoner randomly and ask him to go to living room.
- Prisoner can toggle the light bulb if he wishes to do (when he is in living room).
- Warden lays down a condition (Basis of puzzle).
- If any of the prisoners can tell with certainty that all other prisoners has spent a night in living room, then warden will free all 100 prisoners.
- But, if prisoner’s claim (that all prisoners has spent a night in living room) is false, then warden will shot all 100 prisoners.
- Warden allowed the prisoners to have one meeting (Before, Warden will ask questions to prisoners) and devise a strategy, so that they can have 100% sure in their claim, after the meeting prisoners are not allowed to communicate with each other.
What plan prisoners should make, so that they are 100% sure in their claim?
Solution of 100 prisoners & a light bulb puzzle:
- As per problem, there is no limit the number of times a prisoner can go to living room, It will lay the foundation for our solution to problem statement.
- In a meeting prisoners decided to have one leader (prisoner) and they devise the strategy as follows.
- If any prisoner goes to living room except leader
- If prisoner never turned on the light on before and currently light bulb is off
- Prisoner will turn on the light.
- If light is already on.
- Prisoner will ignore it i.e. will not do anything.
- If prisoner never turned on the light on before and currently light bulb is off
- If leader prisoner goes to living room.
- If light is on.
- Leader prisoner increment its count (initially its zero).
- Turns off the light.
- When count reaches 99, It means all other 99 prisoners been to living room.
- Leader prisoner will be 100% in their claim.
- If light is off.
- Leader prisoner would not do anything in the living room.
- If light is on.
As discussed, when count of leader prisoner reaches 99, then prisoners are 100% sure in their claim.