From The Sunday Times, 10th August 1975 [link]
A farmer grows apples in an orchard divided into plots —three to the East and three to the West of a central path. The apples are of two types — for eating (Cox, Laxton, Pearmain) and for cider making (Tremlitt, Coppin, Kingston).
Adjacent plots contain apples of different basic type. The apples are of six colours (red, green, russet, golden, orange, yellow) and of six tastes (sweet, sour, acid, tart, pleasant, bitter).
They ripen at different times, either early or late in July, August and September. Those ripening in early or late September are in plots directly opposite. Those South of Pearmain do not ripen in August. Tart are directly West of the acid variety, which ripens in early August. Yellow apples and those maturing in late September are adjacent. Yellow and orange are of the same type. Orange are North of pleasant and also North of Pearmain. Kingstons are adjacent to golden. Green is South of bitter.
Cox ripen in early July, and Laxtons ripen early in a different month. Tremlitts are red, and Kingstons mature after Coppins, which are not sour.
If cider apples taste unpleasant, what are the characteristics of the apples in North East plot? (Name, colour, taste, ripens).
This puzzle is included in the book The Sunday Times Book of Brain-Teasers: Book 2 (1981).
I think the puzzle as published in The Sunday Times and in the book is open to interpretation, and my first attempt using a reasonable interpretation gave two solutions (neither of which are the published solution). After examining the given solution in the book I think the following wording is clearer:
A farmer grows apples in an orchard divided into plots — three to the East and three to the West of a central track. Adjacent plots are separated by a shared fence. The apples are of two basic types — for eating (Cox, Laxton, Pearmain) and for cider making (Tremlitt, Coppin, Kingston).
Neighbouring plots contain apples of different basic type. The apples are of six colours (red, green, russet, golden, orange, yellow) and of six tastes (sweet, sour, acid, tart, pleasant, bitter).
They ripen at different times, either early or late in July, August and September. Those ripening in early or late September are in plots directly opposite each other. Those directly South of Pearmain do not ripen in August. Tart are directly West of the acid variety, which ripens in early August. Yellow apples and those maturing in late September are in adjacent plots. Yellow and orange are of the same basic type. Orange are directly North of Permain, which are pleasant. Kingstons and golden are in adjacent plots. Green is directly South of bitter.
Cox ripen in early July, and Laxtons ripen early in a different month. Tremlitts are red, and Kingstons mature after Coppins, which are not sour.
If cider apples are neither pleasant nor sweet, what are the characteristics of the apples in North-East plot?
[teaser734]
Jim Randell 2:48 am on 29 September 2024 Permalink |
This Python program runs in 68ms. (Internal runtime is 1.8ms).
from enigma import (divisors_pairs, subsets, multiset, cproduct, decompose, printf) # possible denominations dss = subsets([1, 2, 3, 4, 5], size=3) # possible number of people = n, average spend = a nas = ((n, a) for (n, a) in divisors_pairs(70, every=1) if a < 14) # consider possible (denominations, (people, average)) values for (ds, (n, a)) in cproduct([dss, nas]): # the vicar spent the average amount m = multiset.from_seq(ds, count=2) for vs in m.express(a, k=3): # and the rest spent different amounts (less than 14) for rs in decompose(70 - a, n - 1, increasing=1, sep=1, min_v=4, max_v=13): if a in rs: continue # check each amount can be made if not m.expressible(rs, k=3): continue # output solution printf("n={n}: a={a} ds={ds} rs={rs} -> vicar = {vs}", vs=list(vs.sorted()))Solution: The vicar bought items priced: £2, £3, £5.
So the vicar spent £10, which is the mean amount among 7 people spending £70.
The others spent: £7, £8, £9, £11, £12, £13, which brings the total spend to £70.
We can actually break down each purchase:
LikeLike
Frits 5:05 am on 30 September 2024 Permalink |
from itertools import product, combinations # combinations of three different prices prices = list(combinations(range(1, 6), 3)) # possible price distributions dist = set(p for p in product(range(3), repeat=3) if sum(p) == 3) # choose number of customers for n in range(len(dist), 0, -1): avg, r = divmod(70, n) if avg >= 14: break if r: continue # choose three different prices for ps in prices: # choose <n> price distributions for ds in combinations(dist, n): spent_amnts = {sum(x * y for x, y in zip(ps, d)) for d in ds} # sum spent amounts is 70 and the average must be present if avg not in spent_amnts or sum(spent_amnts) != 70: continue # all different amounts and less than the Vicar spent last year if len(spent_amnts) != n or max(spent_amnts) >= 14: continue # price distributions of the items that the Vicar bought v_dist = [d for d in ds if sum(x * y for x, y in zip(ps, d)) == avg][0] v_amnts = [[ps[i]] * v_dist[i] for i in range(3) if v_dist[i]] print("answer:", [y for x in v_amnts for y in x])LikeLike