Skip to content

Instantly share code, notes, and snippets.

@olehermanse
Created December 6, 2016 00:14
Show Gist options
  • Save olehermanse/fbe18e7c739327f4dde7ca2e3b2cab74 to your computer and use it in GitHub Desktop.
Save olehermanse/fbe18e7c739327f4dde7ca2e3b2cab74 to your computer and use it in GitHub Desktop.
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