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 3:58 am on 6 October 2024 Permalink |
I think the puzzle could be clearer on what constitutes the “lowest possible values”. I went for the values with the smallest sum, but you could go for the smallest maximum value (although in the end both these give the same answer).
I also assumed that numbers could be repeated on a reel (as the puzzle does not state that they are all different, and it is usual for the reels on a fruit machine to have repeated symbols). However we do get a plausible looking answer with the additional constraint that they are all different.
(I have opened a discussion topic if you have thoughts on these issues [link]).
There are 5^3 = 125 possible positions of the reels, each equally likely, so the total take is £125. And if the total payout among all positions is 80% of this, it is £100.
from enigma import (irange, decompose, primes, cproduct, printf) primes.expand(113) # max possible prime # check a set of reels; return (<total-take>, <total-payout>) def check(rs): t = w = 0 for ns in cproduct(rs): t += 1 if ns == (5, 5, 5): w += 52 elif sum(ns) in primes: w += 2 return (t, w) # the first two reels r1 = [1, 2, 3, 4, 5] r2 = [5, 6, 7, 8, 9] # consider total sum of the four 2-digit numbers for t in irange(40, 396): f = 0 # construct possible third reels for ns in decompose(t, 4, increasing=1, sep=0, min_v=10, max_v=99, fn=list): r3 = [5] + ns (tot, pay) = check([r1, r2, r3]) if pay == 100: # output solution printf("{r3} -> ({tot}, {pay})") f += 1 if f > 0: breakIf repeated values are allowed:
Solution: The 4-digit values with the lowest total are: 14, 14, 14, 14. (total = 56)
If all values have to be different:
Solution: The 4-digit values with the lowest total are: 14, 15, 16, 24. (total = 69)
The second one was the published solution.
To see the solution to the alternative puzzle where the four 2-digit numbers are all different, you just need to pass [[
sep=1]] to [[decompose()]] at line 24.I think it is likely that this is the answer that the setter was after. [This has now been confirmed].
LikeLiked by 1 person
Frits 4:36 am on 6 October 2024 Permalink |
from itertools import combinations_with_replacement as cwr, product # determine suitable primes up to 99+5+9 P = {3, 5, 7} P = {x for x in range(11, 114, 2) if all(x % p for p in P)} score = lambda seq: 52 if seq == (5, 5, 5) else (2 * (sum(seq) in P)) d1 = range(1, 6) d2 = range(5, 10) # select four 2-digit numbers for the third dial for n4 in cwr(range(10, 100), 4): d3 = (5, ) + n4 # play 5^3 games with every possible outcome # it should pay out 4 * 5^2 pounds (80%) if sum(score(p) for p in product(d1, d2, d3)) == 100: print("answer:", n4) exit() # lowestLikeLike
ruudvanderham 1:12 pm on 6 October 2024 Permalink |
The program below finds all two digit numbers that lead to a payout of 100:
import itertools from istr import istr for d3 in range(10, 100): payout = 52 for d1 in range(1, 6): for d2 in range(5, 10): if istr.is_prime(d1 + d2 + d3): payout += 4 * 2 if istr.is_prime(d1 + d2 + 5): payout += 2 if payout == 100: print(d3, end=" ")If the digits may be the same, we pick four times the lowest value.
If the digits have to be different, we pick the four lowest values.
LikeLike
Frits 8:39 am on 7 October 2024 Permalink |
Using a different interpretation of “lowest possible values”.
from itertools import product # determine suitable primes up to 99+5+9 P = {3, 5, 7} P = {x for x in range(11, 114, 2) if all(x % p for p in P)} payout = lambda seq: 52 if seq == (5, 5, 5) else (2 * (sum(seq) in P)) d1 = range(1, 6) d2 = range(5, 10) n_rng = [5] + list(range(10, 100)) # payouts per number on the 3rd dial pay = {n: sum(payout(p) for p in product(d1, d2, [n])) for n in n_rng} # retrieve the lowest number on the 3rd dial for a specific payout low = {v: min([k for k in pay.keys() if pay[k] == v]) for v in pay.values()} todo = 100 - pay[5] # total expected payout is 0.80 * 5^3 # select four 2-digit numbers for the third dial so the combined payout is # equal to <todo> n4s = [[low[x] for x in p] for p in product(low, repeat=4) if sum(p) == todo] # assume “lowest possible values" means minimal sum mn = min([sum(n4) for n4 in n4s]) print("answer:", ' or '.join(str(sorted(n4)) for n4 in n4s if sum(n4) == mn))LikeLike