Riddler 2018-09-07 Classic, "I’d Like To Use My Riddler Lifeline"
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 open_pack(set_size=100): | |
return random.sample(xrange(set_size), 10) | |
def collect(set_size=100): | |
owned = set([]) | |
packs_bought = 0 | |
while len(owned) != set_size: | |
packs_bought += 1 | |
for card in open_pack(set_size): | |
owned.add(card) | |
return packs_bought | |
def simulate(trials=100, set_size=100): | |
results = [] | |
p = 0 | |
for i in xrange(1, trials+1): | |
results.append(collect(set_size)) | |
return float(sum(results)) / trials | |
print simulate(10000, 100) #prints ~50.0 | |
print simulate(10000, 300) #prints ~186.6 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment