Teaser 3247: In the bag
From The Sunday Times, 15th December 2024 [link] [link]
My set of snooker balls comprises 15 red balls, 6 “colours” (not red) and a white ball. From these, I have placed a number of balls in a bag such that if four balls are drawn at random the chance of them all being red is a two-digit whole number times the chance of them all being colours.
If I told you this whole number you would not be able to determine the numbers of reds and colours in the bag, but I can tell you that drawing four colours is a one in a whole number chance.
How many balls are in the bag and how many of them are red?
[teaser3247]



Jim Randell 6:52 am on 15 December 2024 Permalink |
See also: Teaser 2768 (also called “In the bag”).
This Python program runs in 71ms. (Internal runtime is 1.5ms).
from enigma import (Rational, irange, multiset, multiply, div, filter_unique, unpack, printf) Q = Rational() # calculate probability of drawing <k> balls of type <X> from multiset <bs> def prob(bs, k, X): (n, t) = (bs.count(X), bs.size()) if n < k or t < k: return 0 return multiply(Q(n - i, t - i) for i in irange(k)) # generate possible subsets of balls with the required probabilities def generate(balls): bs0 = multiset(R=4, C=4) # minimum number of reds/colours for bs in balls.difference(bs0).subsets(): bs.update(bs0) (pR, pC) = (prob(bs, 4, 'R'), prob(bs, 4, 'C')) k = div(pR, pC) if k is None or k < 10 or k > 99: continue yield (bs, pR, pC, k) # the set of snooker balls balls = multiset(R=15, C=6, W=1) # knowing the whole number <k> does not let us determine the number of reds and colours in <bs> fn_k = unpack(lambda bs, pR, pC, k: k) fn_RC = unpack(lambda bs, pR, pC, k: (bs.count('R'), bs.count('C'))) for (bs, pR, pC, k) in filter_unique(generate(balls), fn_k, fn_RC).non_unique: # but we want cases where pC = 1/N (for some integer N) if pC.numerator != 1: continue # output solution printf("{n} balls {bs} -> pR = {pR}, pC = {pC}, k = {k}", n=bs.size(), bs=bs.map2str())Solution: There are 13 balls in the bag, and 8 of them are red.
And the other 5 are colours.
The probability of drawing 4 red balls is:
And the probability of drawing 4 coloured balls is:
So the probability of drawing 4 red balls is 14 times the probability of drawing 4 coloured balls.
But knowing this value is not sufficient, as there are 4 possible candidates where k = 14:
But only the first of these has pC = 1/N for some integer N.
LikeLike