Created
December 6, 2016 00:14
-
-
Save olehermanse/fbe18e7c739327f4dde7ca2e3b2cab74 to your computer and use it in GitHub Desktop.
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 | |
attempts = 20000 | |
choices = 25 | |
def one_test(possibilities): | |
found = [] | |
num = 0 | |
while len(found) < possibilities: | |
r = random.randint(1,possibilities) | |
if r not in found: | |
found.append(r) | |
num += 1 | |
return num | |
results = [] | |
for i in range(attempts): | |
results.append(one_test(choices)) | |
print("Average over {} runs: {}".format(attempts, sum(results)/attempts)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment