From The Sunday Times, 8th November 1970 [link]
Three men from the Absorbers’ Association, three from Bacchante’s Bank and three from the Convivial Corporation, took a drink together.
From each concern, one man drank sherry, one gin and one whisky. Of the three choosing sherry, one chose medium, one dry and one extra dry. With gin, one took tonic, one lemon and one vermouth. With whisky, one plain water, one soda water and one dry ginger.
The dry sherry drinker did not belong to the same concern as the plain water man, nor to the same concern as the vermouth man. The drinkers of dry ginger, lemon and medium sherry were from three different concerns.
Either the tonic man or plain water man (but not both) was from the Absorbers’ Association. The selectors of soda and vermouth were not colleagues and neither represented Bacchante’s Bank.
The tonic man belonged either to the same concern as the dry sherry drinker or to the same concern as the medium sherry man.
Which type of sherry was chosen by a Convivial Corporation man and what did [the] other men from that same concern take with gin and take with whisky?
This puzzle is included in the book Sunday Times Brain Teasers (1974).
[teaser493]
Jim Randell 9:46 am on 5 September 2019 Permalink |
We can label the 7 non-empty parts of the Venn diagram, F, H, R, FH, FR, HR, FHR, according to which sports each member plays.
We can then express the constraints in terms of these 7 integer variables.
I expressed the constraints as a MiniZinc model, and then used the minizinc.py wrapper to collect the solutions and count them using Python.
This program runs in 263ms.
from minizinc import MiniZinc, var from enigma import multiset, printf # decision variables, the 7 non-empty areas of the venn diagram vs = "F H R FH FR HR FHR" # the MiniZinc model model = f""" % declare the variables {var('0..26', vs.split())}; % there are 26 members in total constraint F + H + R + FH + FR + HR + FHR = 26; % F's form a football team (11) constraint F + FH + FR + FHR = 11; % H's form a hockey team (11) constraint H + FH + HR + FHR = 11; % R's form a rugby team (15) constraint R + FR + HR + FHR = 15; % total number of two sports = number of only rugby constraint FH + FR + HR = R; % R is less than 1/3 of the total membership (= 26) constraint 3 * R < 26; solve satisfy; """ # create the model m = MiniZinc(model) # record FHR values r = multiset() # solve it for (F, H, R, FH, FR, HR, FHR) in m.solve(result=vs): printf("[F={F} H={H} R={R} FH={FH} FR={FR} HR={HR} FHR={FHR}]") r.add(FHR) # output solutions for (k, v) in r.most_common(): printf("FHR = {k} [{v} solutions]")Solution: 2 members play all three sports.
There are 7 possible solutions:
LikeLike
Jim Randell 12:32 pm on 5 September 2019 Permalink |
And here’s a solution in Python. It runs in 93ms.
Run: [ @repl.it ]
from enigma import (irange, multiset, printf) # decompose t into k numbers (min value m) def decompose(t, k, m=0, s=[]): if k == 1: yield s + [t] else: for x in irange(m, t - k * m): yield from decompose(t - x, k - 1, m, s + [x]) # record FHR values r = multiset() # can form a football team of 11 for (F, FH, FR, FHR) in decompose(11, 4): # can form a hockey team of 11 for (H, HR) in decompose(11 - FH - FHR, 2): # number of rugby only = total number of two sports R = FH + FR + HR # can form a rugby team of 15 if not (R + FR + HR + FHR == 15): continue # R is less than 1/3 of the total membership (26) if not (3 * R < 26): continue # total membership is 26 if not (F + H + R + FH + FR + HR + FHR == 26): continue printf("[F={F} H={H} R={R} FH={FH} FR={FR} HR={HR} FHR={FHR}]") r.add(FHR) # output solutions for (k, v) in r.most_common(): printf("FHR = {k} [{v} solutions]")LikeLike
John Crabtree 12:41 am on 6 September 2019 Permalink |
Let R members play rugby only and let A members play all three sports.
Considering that there are 26 members and 37 players leads to 2A + R = 11,
R ≤ 7 and so A ≥ 2.
15 players play rugby, ie A + 2R ≥ 15, which leads to 3A ≤ 7.
And so 2 members play all three sports.
LikeLiked by 1 person