Heaviest Weight, Heavier Pan
Eight distinct weights, 101 g through 108 g, are split uniformly at random into two pans of four. This program counts how often the pan holding the 108 g weight comes out strictly heavier:
from itertools import combinations
weights = list(range(101, 109))
total = wins = 0
for pan in combinations(weights, 4):
if 108 not in pan:
continue # count every split once
other = [w for w in weights if w not in pan]
total += 1
if sum(pan) > sum(other):
wins += 1
print(total, wins, round(wins / total, 3))
It prints the size of the sample space, then the number of wins, then a probability. What is that probability? Answer format: round to 3 decimal places.
Sign in to answer questions and track your progress
Sign In