Enigmatic Code

Programming Enigma Puzzles

Tantalizer 489: Buttons and bows

From New Scientist #1040, 24th February 1977 [link]

Great is the rejoicing in the firm of Furbelows over the engagement of Bertha Button of the button department to Bertie Bow, beau of the bows. Since Miss button is the fanciest of the three spinsters in buttons, while Mr Bow is quite the most eligible of the eight bachelors in the bows, it may seem none too astonishing that Cupid has singled them out. But, considering the number of bachelors in buttons and of spinsters in bows, it is as well that the merry archer does not loose his shaft at random. For, had he done so, the chances are 29 to 23 in favour of an engagement between two members of the same department.

How many bachelors are there in buttons?

[tantalizer489]

4 responses to “Tantalizer 489: Buttons and bows”

1. Jim Randell 22 February 2017 at 11:11 am

We are interested in the pairing of a male and a female.

The information given allows us to derive Diophantine Equations for the number of bachelors in the buttons department (m) in terms of the number of spinsters in the bows department (f).

m = (184f – 696) / (29f – 69)

Or, conversely:

f = (69m – 696) / (29m – 184)

This Python program considers increasing values for m until a suitable value for f is found.

It runs in 43ms.

```# suppose there are m bachelors in buttons, and f spinsters in bows.
#
# then the chances of a same department paring are:
#
# (3m + 8f) / (24 + mf) = 29 / 23
#
# f = (696 - 69m) / (184 - 29m)

from itertools import count
from enigma import printf

for m in count(1):
(f, r) = divmod(696 - 69 * m, 184 - 29 * m)
if r == 0 and f > 0:
printf("m={m} f={f}")
break
```

Solution: There are 5 bachelors in buttons. (And 9 spinsters in bows).

There are two further integer solutions to the Diophantine Equations, but these involve negative numbers.

```>>> from sympy.solvers.diophantine import diophantine
>>> from sympy.abc import m, f
>>>
>>> diophantine((69 * m + 184 * f) - (696 + 29 * m * f))
{(3, -8), (9, 5), (-3, 8)}
```

They are: m = –8, f = 3 and m = 8, f = –3.

2. Hugh Casement 22 February 2017 at 2:12 pm

Is it just chance that 3 × 5 + 8 = 23 and 3 × 8 + 5 = 29,
or could it be that your expressions linking f and m are unnecessarily complicated?
I can’t see how they’re derived (though I may be blind).

• Jim Randell 22 February 2017 at 3:24 pm

I did omit the comment from my code deriving the formula, but the formula comes from the given odds.

There are 3 females in the button department and f in the bows department.
There are 8 males in the bows department and m in the buttons department.

If we pair a female with a male we get the following pairings:

female (buttons) × male (bows) = 3×8 = 24 (different departments)
female (buttons) × male (buttons) = 3×m (same department)
female (bows) × male (bows) = f×8 (same department)
female (bows) × male (buttons) = f×m (different departments)

The chances of a pairing in the same department is 29 to 23 in favour, so:

(same) / (different) = 29 / 23
(3m + 8f) / (24 + mf) = 29 / 23
69m + 184f = 696 + 29mf

And this is the equation I started with.

• Hugh Casement 22 February 2017 at 3:44 pm

Thank you, Jim.
I’ve just derived the same relationship, but you beat me to it.
My simplified expression works only because there happen to be three times as many lassies in bows as in buttons.

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