Enigmatic Code

Programming Enigma Puzzles

Enigma 334: Biggabagg’s Bettamix

From New Scientist #1482, 14th November 1985 [link]

My two elder sisters love Mr Ivor Fitzclarence Biggabagg’s seductive sweet-counter. His “Bettamix”, a random mixture of liquorice and blackcurrant gums, is splendid value, they reckon: each buys a quantity every week. When they get home, they allow me to pick one gum for myself. Isn’t that nice of them?

I hate liquorice and love blackcurrant, but unfortunately they won’t let me just look and choose a blackcurrant gum. They do however let me first inspect the contents of each bag. Then I can either choose one bag at random and then pick a gum at random from it or mix up the contents of both bags and then pick a gum at random.

You will be glad to hear that I have now worked out a simple rule for deciding which of the two methods gives me the better chance of a blackcurrant gum.

I was surprised last week to find that it didn’t matter which method I chose. Anne’s bag contained 6 liquorice and 14 blackcurrant gums. Pam’s held 18 liquorice and quite a few blackcurrant.

Before I had a chance to choose, Anne removed some of the blackcurrant gums from Pam’s bag and asked me, in this new situation, to decide which method. And again I was surprised to find that it didn’t matter which method I chose.

How many blackcurrants did Anne remove?

Note: A correction was issued to this puzzle in New Scientist #1485 (along with the solution), the puzzle statement above has been modified accordingly.

[enigma334]

One response to “Enigma 334: Biggabagg’s Bettamix”

1. Jim Randell 26 February 2016 at 9:43 am

For Anne’s bag (6 liquorice + 14 blackcurrant), the probability of choosing a blackcurrant from Anne’s bag is:

PA = 14/20 = 7/10

For Pam’s bag (18 liquorice + x blackcurrant), the probability of choosing a blackcurrant from Pam’s bag is:

PB = x / (18 + x)

So the probability of choosing a blackcurrant using method 1 is:

P1 = (1/2)(14/20) + (1/2)(x / (18 + x))

Mixed together there are 24 liquorice + (14 + x) blackcurrant, the probability of choosing a blackcurrant is:

P2 = (14 + x) / (38 + x)

We are interested in cases where these last two probabilities are equal.

This Python program considers increasing values of x, until it gets two values where P1 and P2 are the same. It runs in 52ms.

```from fractions import Fraction as F
from itertools import count
from enigma import printf

# probability of getting a desired sweet from Y good sweets and N bad sweets
def P(N, Y):
return F(Y, N + Y)

# consider x, the number of good sweets in Pam's bag
s = list()
for x in count(1):

# method 1
p1 = F(1, 2) * (P(6, 14) + P(18, x))
# method 2
p2 = P(24, 14 + x)

# look for values with the same probability
if p1 == p2:
printf("[x={x} p1={p1} p2={p2}]")
s.insert(0, x)
# when we have two values we are done
if len(s) == 2:
r = s[0] - s[1]
printf("removed = {r} [before = {s[0]}, after = {s[1]}]")
break
```

Solution: Anne removed 40 blackcurrants.

Initially there were 42 blackcurrants in Pam’s bag, and probability of choosing a blackcurrant is 7/10 (70%) by either method.

After Anne removes 40 blackcurrants from Pam’s bag there are only 2 remaining, and the probability of choosing a blackcurrant is now 2/5 (40%) by either method.

Manually we can rewrite the equation P1 = P2 as:

x² − 44x + 84 = 0 (x ≠ −18, x ≠ −38)

Which factorises as:

(x − 2)(x − 42) = 0

Giving the solutions x = 2, x = 42.

This site uses Akismet to reduce spam. Learn how your comment data is processed.