Matching Sums
Bob's machine and Alice's machine each draw two integers uniformly and independently from and report the sum of the pair. The script computes the probability that the two reported sums are equal.
from collections import Counter
from itertools import product
counts = Counter(a + b for a, b in product(range(1, 11), repeat=2))
total = sum(counts.values()) # 100 equally likely pairs
collision = sum((c / total) ** 2 for c in counts.values())
print(round(collision, 3))
What does it print?
Answer format: round to 3 decimal places.
Sign in to answer questions and track your progress
Sign In