15 years ago, when I was in university, I heard an interesting riddle:

100 prisoners are imprisoned in solitary cells. Each cell is windowless and soundproof. There’s a central living room with one light bulb; the bulb is initially off. No prisoner can see the light bulb from his or her own cell. Each day, the warden picks a prisoner equally at random, and that prisoner visits the central living room; at the end of the day the prisoner is returned to his cell. While in the living room, the prisoner can toggle the bulb if he or she wishes. Also, the prisoner has the option of asserting the claim that all 100 prisoners have been to the living room. If this assertion is false (that is, some prisoners still haven’t been to the living room), all 100 prisoners will be shot for their stupidity. However, if it is indeed true, all prisoners are set free and inducted into MENSA, since the world can always use more smart people. Thus, the assertion should only be made if the prisoner is 100% certain of its validity.

Before this whole procedure begins, the prisoners are allowed to get together in the courtyard to discuss a plan. What is the optimal plan they can agree on, so that eventually, someone will make a correct assertion?

At the time, I was able to come up with an answer, but it wasn’t the optimal answer. Over the years, I’ve thought about this problem on and off. About 5 years after first hearing the problem, I ran across the actual riddle on the wu riddles forum and saw that the solution I gave was not optimal and spent a while thinking about it again.

I ended up implementing several strategies, but only one of them was actually good: the naive strategy can take about 10,000 days, but the optimal listed by wu riddles takes only 3,500 days. I was able to implement a strategy that takes 5,000 days but haven’t been able to improve it further yet.

I once told this problem to someone else who is really smart and he said it was boring. When I asked him what the number of days his solution took, I realized that he only solved the outer shell. He hasn’t yet given the most optimal solution, so I thought it was funny that he also stopped thinking about the problem once he found the initial solution.