Brain-Teaser 545: Gold Cup
From The Sunday Times, 5th December 1971 [link]
Although 42 horses (numbered 1 to 42) were originally entered for the Teaser Gold Cup, only 38 took part in the race.
The number of the horse which came second in the race exceeded the number of the winner by the same number as that by which the number of the third horse exceeded the number of the second.
When the numbers of the 4 non-runners were placed in numerical order, the difference between each number and the next was the same in every case, and that difference was the same as the difference between the number of the horse which won the race and the number of the horse which came second.
The sum of the numbers of the highest and lowest of the four non-runners was equal to the sum of the numbers of the horses which came first, second, and third.
One of the first three horses was numbered 15. Horses numbered 24 and 28 fell at the third fence, and were not remounted.
What were the numbers of the 4 non-runners?
[teaser545]

Jim Randell 11:18 am on 1 October 2024 Permalink |
Here is a solution using the [[
SubstitutedExpression]] solver from the enigma.py library.It runs in 90ms. (Internal runtime of the generated program is 12ms).
#! python3 -m enigma -rr SubstitutedExpression # suppose the first three horses are: A, B, C (ordered by number) # and the four non-runners are: W, X, Y, Z (ordered by number) --base=43 --digits="1-42" --distinct="ABCWXYZ" --invalid="24|28,ABCWXYZ" # A, B, C are ordered by number "A < B" "B < C" # and form an arithmetic progression (common diff = D) "B - A = D" "C - B = D" # one of them is 15 "15 in {A, B, C}" # W, X, Y, Z are ordered by number "W < X" "X < Y" "Y < Z" # and form an arithmetic progression (common diff = D) "X - W = D" "Y - X = D" "Z - Y = D" # equal sums "W + Z == A + B + C" --template=""Solution: The 4 non-runners were: 12, 19, 26, 33.
Which forms an arithmetic progression with common difference of 7.
The horses in the first 3 places were: 8, 15, 22.
Which also form an arithmetic progression with a common difference of 7.
The sum of the numbers of the first 3 horses is 8 + 15 + 22 = 45, the same as the sum of the highest and lowest numbered non-runners 12 + 33 = 45.
LikeLike
Ruud 4:36 pm on 1 October 2024 Permalink |
import itertools for non_runners in itertools.combinations(set(range(1, 43)) - {15, 24, 28}, 4): if (diff := non_runners[1] - non_runners[0]) == non_runners[2] - non_runners[1] == non_runners[2] - non_runners[1] == non_runners[3] - non_runners[2]: runners123 = set(range(1, 43)) - set(non_runners) - {24, 28} for first in runners123: second = first + diff third = second + diff if second in runners123 and third in runners123 and 15 in {first, second, third} and first + second + third == non_runners[0] + non_runners[3]: print(f"{non_runners=} {first=} {second=} {third=}"), which prints:
LikeLike
GeoffR 7:23 pm on 1 October 2024 Permalink |
% A Solution in MiniZinc include "globals.mzn"; var 1..42:NR1; var 1..42:NR2; var 1..42:NR3; var 1..42:NR4; var 1..42:W1; var 1..42:W2; var 1..42:W3; constraint all_different ([NR1, NR2, NR3, NR4, W1, W2, W3]); constraint W2 - W1 == W3 - W2; constraint NR1 < NR2 /\ NR2 < NR3 /\ NR3 < NR4; constraint NR2 - NR1 == NR3 - NR2 /\ NR3 - NR2 == NR4 - NR3; constraint NR2 - NR1 == W2 - W1; constraint NR1 + NR4 == W1 + W2 + W3; constraint sum ([W1 == 15, W2 == 15, W3 == 15]) == 1; var set of int: horses = {NR1, NR2, NR3, NR4, W1, W2, W3}; constraint card ({24, 28} intersect horses) == 0; solve satisfy; output ["Numbers of non-runners = " ++ show([NR1, NR2, NR3, NR4]) ++ "\nWinning numbers = " ++ show([W1, W2, W3]) ]; % Numbers of non-runners = [12, 19, 26, 33] % Winning numbers = [8, 15, 22] % ---------- % ==========LikeLike