## 100 Prisoners and a Light Bulb

Do you want a real challenging mathematical brain teaser? Help these 100 prisoners escape.

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?

Note 1: What is meant by optimal? If your solution is optimal, it means you can prove that no other algorithm can produce a lower average running time. This is usually very hard to do though. So the best we can do in the meantime is try to beat the best average running time we know of. The number to beat so far is around 3500 days. If you get a number around 27-28 years, then you’ve found the solution most people who solve the puzzle come up with. However, it’s not optimal.

Note 2: How to compute average running time? The preferred method is to do a probabilistic analysis using pencil and paper. But if you haven’t learned about stuff like that, a much simpler way is to just program your solution and run it maybe 100 times, recording how many days elapsed in each invocation. Afterwards you should have an array of 100 numbers. Now take the average of all them, and you’ll have an empirical average which is close to the theoretical one.

Source

** Note: Some posts on Math-Fail are user-submitted and NOT verified by the admin of the site before publication. If you find this post to be distasteful, non-math related, ?or something worse?, then definitely leave a comment letting me know. Thanks very much! Mike **

0  5

2. Charon l'Cypher

27-28 years is for losers. I got 146 years!

2  0

• Charon l'Cypher

Got 29 years. Had bug in the first implementation. ðŸ˜³

0  0

• its ok, a century and a half is a much more hilarious answer

0  0

If you plan to involve the state of the lightbulb as means to transfer information between the prisoners, then don’t forget that the eco friendly warden will make sure that the lightbulb is turned off at the end of each day to save electricity (and he won’t tell anyone in which state he found it) ;P

0  0

4. I’ve figured out my answer (without cheating and looking at any other solutions of course, so I’m excited about that) but I’m going to have to struggle for a little while to write a program to find an estimated runtime as I haven’t yet learned how to do that on paper.

And lol @ Spork. I’m rather sure that your “additional challenge” makes it impossible as I’m pretty sure the only information transfer allowed is the state of the bulb at the beginning of the next day. (Assume the warden keeps the room clean everyday and looking exactly as it had on the first day with the possible exception being the state of the lightswitch)

0  0

• oh noes!! assuming my code wasn’t faulty (I might still have an off by one error somewhere), I’m averaging…250 years…… Perhaps I had the same problem with my code as Charon was having.

0  0

• Okay… I figured out a different answer that gives 27-28 years. Probably the same answer as others now. Still.. if people thought 150 years was bad., the 250 years is just…

0  0

5. I got 7166.4542 days or about 20 years.
I’m curious what solution gives 27 years….
I think I know a way to reduce my time even further.