Brain-Teaser 693: Ready …
From The Sunday Times, 27th October 1974 [link]
The Phytteness School marathon attracted 16 entrants this year. Each of the five houses entered a team of three runners, and the field was made up by the maths master, Des Chappelle. The school houses were competing for the trophy. The number of points by each entrant would be equal to his finishing position.
The five houses tied for the cup, their totals being equal, although no two competitors tied for the same position. In order to determine the order in which the houses would hold the cup (they had agreed to hold it for 73 days each), they multiplied the finishers’ positions together in each house. The house with the smallest product, Black, would hold the cup first and so on to the house with the largest product, Blue, who hold it last. Unfortunately, Green and White houses still tied, and had to be separated by the toss of a coin.
Des noted later that no house had had two finishers in consecutive positions, although Green house would have achieved this had he not managed to get between two of their runners right on the line.
In what positions did the Red house runners finish?
This puzzle is included in the book The Sunday Times Book of Brain-Teasers: Book 2 (1981). The puzzle text above is taken from the book.
[teaser693]
Jim Randell 8:00 am on 3 May 2022 Permalink |
There are T(16) = 136 points available, but Des finished between two of the other runners, so he must have finished with 2 – 15 points. And the remaining positions must be shared between the 5 houses (3 positions each) to give the same sum.
This Python program chooses a position for Des that give viable possible totals for each house, and then partitions the remaining positions among the houses. The groupings are then sorted by product, and the 3 groups in the middle of the field must have 2 products between them. The group with the unique product are Red.
The program runs in 59ms (internal run time is 312µs).
Run: [ @replit ]
from enigma import (tri, tuples, irange, div, diff, multiply, group, filter2, singleton, printf) # total number of points T = tri(16) # check increasing integer sequence <s> has no consecutive elements check = lambda s: all(y - x > 1 for (x, y) in tuples(s, 2)) # partition the values into <k>-length groups, each sums to <t> def partition(vs, k, t, ss=[]): if len(vs) == k: if sum(vs) == t and check(vs): yield ss + [tuple(vs)] else: v0 = vs[0] for (i, v1) in enumerate(vs): if i == 0: continue v2 = t - (v0 + v1) if not (v2 > v1): break if v2 in vs: s = (v0, v1, v2) if check(s): yield from partition(diff(vs, s), k, t, ss + [s]) # consider position for D (between 2 others) for D in irange(2, 15): # calculate points for each house H = div(T - D, 5) if H is None: continue # partition the remaining positions into groups of 3 for ss in partition(diff(irange(1, 16), [D]), 3, H): # sort the groups by product (largest first) ss.sort(key=multiply, reverse=1) # find the products of the middle three (G, W, R) p = group(ss[1:-1], by=multiply) if len(p.keys()) != 2: continue Rs = Ws = Gs = None for (k, vs) in p.items(): if len(vs) == 1: # red has a unique product Rs = vs[0] else: # green/white have shared products; green has D - 1 and D + 1 (Gs, Ws) = filter2((lambda s: D - 1 in s and D + 1 in s), vs, fn=singleton) if Rs and Ws and Gs: # output solutions printf("D={D}; H={H}") printf("houses = {ss}") printf("-> blue = {ss[0]}") printf("-> green = {Gs}") printf("-> white = {Ws}") printf("-> red = {Rs}") printf("-> black = {ss[-1]}") printf()Solution: Red house finished 2nd, 9th, 14th.
The points awarded were:
LikeLike
GeoffR 10:32 am on 3 May 2022 Permalink |
LikeLike