Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-178

Coupon Collector with Pairs (Seeded)

Problem

Estimate by simulation the expected number of draws needed to see every one of n coupon types at least twice. Run trials experiments with random.Random(seed), stopping each when all counts reach 2, and return the average number of draws. Return 0.0 for n <= 0 or trials <= 0.

Hint

Count how many types have reached two copies and stop when all have.

Test cases

case 1
in: [1,100,0]
expected: 2
case 2
in: [5,300,42]
expected: 19.02
case 3
in: [10,200,7]
expected: 46.415
case 4
in: [0,5,1]
expected: 0
Starter codePython
import random


def coupon_pairs_expected_simulation(n, trials, seed):
    # Your code here
    pass

4 test cases · run your code against them in the editor