3 ms·
Good guess. 100 runs: Average: 10163 Lowest: 7762 Highest 12391 If I knew how to paste code in here, I would show you my simple python script to test it. Edit
by mrtron 19y ago
Good guess.
100 runs:
Average: 10163
Lowest: 7762 Highest 12391
If I knew how to paste code in here, I would show you my simple python script to test it.
Edit:
1000 runs:
Average: 10109
Lowest: 7389 Highest 13461
- brett 19y agohttp://news.ycombinator.com/item?id=32766 http://news.ycombinator.com/item?id=32766 It would probably be helpful if that information was readily available via a link near the "add comment" and "reply" buttons
- oditogre 19y agoAlong with all other relevant info for working with text in comments.
- mrtron 19y agoThanks. import random def run(): prisoners = {} for x in range(100): prisoners[x]=0 days=0; counter=0; bulb=0 while counter<100: prisoner = random.randint(0, 99) days += 1 if prisoner == 0: if bulb == 1: bulb = 0; counter += 1 else: if prisoners[prisoner] == 0 and bulb == 0: bulb=1 return days