Since the third team's lead runner's place was the same as the total of the first team's first three runners' places, that was at least 6th place (1+2+3), the basis for the "IF ix3 > 5 THEN" statement in the program below. The identifier "1" designates a player on the team which had the first runner across the finish line, but not necessarily the winning team. The identifier "3" refers to a member of the last-place team. Actual counts determine whether the team designated by the "1" or by the "2" was the winning team.
DECLARE SUB permute (a$)
CLS
o$ = "111111222222333333"
h$ = o$
DO
ix3 = INSTR(o$, "3")
IF ix3 > 5 THEN
ix31 = ix3
ix32 = INSTR(ix31 + 1, o$, "3")
ix33 = INSTR(ix32 + 1, o$, "3")
ix34 = INSTR(ix33 + 1, o$, "3")
score3 = ix31 + ix32 + ix33 + ix34
ix11 = 1
ix12 = INSTR(ix11 + 1, o$, "1")
ix13 = INSTR(ix12 + 1, o$, "1")
ix14 = INSTR(ix13 + 1, o$, "1")
score1 = ix11 + ix12 + ix13 + ix14
ix21 = INSTR(o$, "2")
ix22 = INSTR(ix21 + 1, o$, "2")
ix23 = INSTR(ix22 + 1, o$, "2")
ix24 = INSTR(ix23 + 1, o$, "2")
score2 = ix21 + ix22 + ix23 + ix24
IF score2 < score1 THEN
winner = 2: best = score2: best2 = score1
ELSE
winner = 1: best = score1: best2 = score2
END IF
IF best2 MOD best = 0 THEN
IF score3 MOD best2 = 0 THEN
IF winner = 1 THEN
IF ix11 + ix12 + ix13 = ix21 + ix22 AND ix21 + ix22 = ix31 THEN
PRINT o$; score1; score2; score3
END IF
ELSE
IF ix21 + ix22 + ix23 = ix11 + ix12 AND ix11 + ix12 = ix31 THEN
PRINT o$; score1; score2; score3
END IF
END IF
END IF
END IF
END IF
permute o$
LOOP UNTIL LEFT$(o$, 2) = "13"
The program itself does not check that each team has a different score, but the results can be examined for that:
121112133313332222 13 39 39
121112231122323333 13 26 52
In the first row, the team designated 2 and that designated 3, each have 39 points. Thus the second row is the answer, and indeed the team designated "1" (the one with the first runner crossing the finish line) did in fact win the race, with 13 points, against 26 and 52 for the other two teams. The team identification for the place positions is 121112231122323333.
From Enigma No. 1418, by Richard England, New Scientist, 18 November 2006.
|