Created
December 11, 2015 13:10
-
-
Save gurgeh/9dbead70b81779e66be7 to your computer and use it in GitHub Desktop.
Notch's lottery question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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