Skip to content

Instantly share code, notes, and snippets.

@gurgeh
Created December 11, 2015 13:10
Show Gist options
  • Save gurgeh/9dbead70b81779e66be7 to your computer and use it in GitHub Desktop.
Save gurgeh/9dbead70b81779e66be7 to your computer and use it in GitHub Desktop.
Notch's lottery question
import random
def timeto(nguys, nwins):
guys = [0] * nguys
i = 0
while True:
i += 1
j = random.randrange(0, nguys)
guys[j] += 1
if guys[j] == nwins:
return i
print sum(timeto(1000000, 10) for _ in range(100)) / 100 # This might take a few minutes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment