#406
The Light Switch Protocol
Also asked as: The 100 prisoners and a light bulb problem · the light switch puzzle
One of the classic quant interview questions, free to read in full.
Problem
100 prisoners are held in isolation. Each day the warden takes one uniformly random prisoner into a room containing a single light switch (initially OFF, and everyone knows it), which the visitor may leave as-is or toggle. At any time, any prisoner may declare "all 100 of us have visited the room." A correct declaration frees everyone; an incorrect one is fatal. Design a strategy that succeeds with certainty, and estimate how long it takes.
Your answer
This one is graded like the real thing: reason it through out loud (structure, key insight, numbers), then reveal and self-grade.