13/17
Part 7 of 7 · Follow-upsLearn and do

Collecting every kind

Three follow-ups come up after these questions. The first is a classic.

The shop puts one of 6 patch designs in every order. How many orders until a customer has all 6? A simulation:

import random

rng = random.Random(5)
designs, trials = 6, 100_000
total = 0
for _ in range(trials):
    seen = set()
    while len(seen) < designs:
        # each order brings one design at random
        seen.add(rng.randrange(designs))
        total += 1
print(f"{total / trials:.1f} orders on average to collect all {designs} designs")
Predict

About how many orders does it take to collect all 6 designs?

Pick one to see what it prints.
Pick an answer above to see the rest