Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

First 99 days:

if bulb on: do not touch

if bulb off:

if you haven't been visited before, consider yourself counted, and do nothing.

if you have been in here before, turn it on. you are now the counter. look at the day number (1-based). if it's day 36, then 35 people (including yourself) have visited the room.

day 100:

if bulb off, and you haven't been there before, declare victory (super lucky!)

if off, but you have been there before, you're the counter and the count is 99.

if bulb on: turn it off.

after day 100:

use the original solution with a counter.

speedup:

you get about 12.2 people counted in the first 100 days. normally it's somewhere around one person counted per 100 days. so total time is around 100 + 87.8*100. a bit better. not near 3500 though.



i wrote code. 1000 trials. naive mean: 10389.832 my strategy's mean: 9392.652

i think the improvement was a little less good than i guessed because i jumpstart getting the first dozen or so people counted, and they are a little easier to count than the last people.


Here's a paper on the subject:

http://www.ocf.berkeley.edu/~wwu/papers/100prisonersLightBul...

It includes my answer :)




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: