# Enigmatic Code

Programming Enigma Puzzles

## Tantalizer 495: Bound variables

From New Scientist #1046, 7th April 1977 [link]

Morning coffee at the Logicians’ Union could be with or without any or all of milk, sugar and biscuits. You ordered as you went in by putting your name on any or all of three lists headed “milk”, “sugar” and “biscuits”.

Well, that was not too hard and, by the time Professor Haarschneider was half way through his seminal paper on Semi-opaque Designators, 21 names appeared under each heading. It fell to Professor Nachtwebel, as president, however, to regroup the names into the appropriate seven subsets. Working on the back of an envelope in Polish notation, he found that no two subsets were the same size, that the smallest had three members and that the largest was of those requiring milk but neither sugar not biscuits.

As it was by now the hour appointed for luncheon, the delegates had to forego coffee. How many of those who would have taken sugar were also hoping for biscuits?

[tantalizer495]

### 2 responses to “Tantalizer 495: Bound variables”

1. Jim Randell 28 December 2016 at 9:18 am

This Python program runs in 56ms.

```from itertools import permutations
from enigma import printf

# consider the subsets M, S, B, MS, MB, SB, MSB
#
# the smallet subset has 3 elements, and all subsets are different
# sizes, so the largest possible size is 21 - (3 + 4 + 5) = 9
#
# so the seven sets are size 3, 4, 5, 6, 7, 8, 9

# the largest set
M = 9

# consider the remaining sets
for (S, B, MS, MB, SB, MSB) in permutations((3, 4, 5, 6, 7, 8)):
# each list has 21 names on
if not(M + MS + MB + MSB == S + MS + SB + MSB == B + MB + SB + MSB == 21): continue
# output solution
printf("S n B = {x} [M={M} S={S} B={B} MS={MS} MB={MB} SB={SB} MSB={MSB}]", x=SB + MSB)
```

Solution: There are 9 people who want both sugar and biscuits.

There is nothing to distinguish S from B, so there are two symmetrical solutions:

M = 9, S = 7, B = 8, MS = 5, MB = 4, SB = 6, MSB = 3
M = 9, S = 8, N = 7, MS = 4, MB = 5, SB = 6, MSB = 3

But the sum SB + MSB is the same in each solution.

As logicians you might think they would realise the was no way to order a coffee without milk, sugar or biscuits, because that would involve writing your name on no lists, and is indistinguishable from the case of not having a drink at all. The solution would seem to be to order coffee with just biscuits and not eat them. (Or maybe they know everyone wants a drink so can make enough black coffees, no sugar, no biscuits to make up the numbers).

2. Hugh Casement 28 December 2016 at 9:44 am

I’m glad you brought up the problem of the (0, 0, 0) set, which struck me as soon as I saw the number seven.  I suspect the possibility had occurred to the logicians but not to the setter of the Tantalizer.