Brain-Teaser 490: Equal marks
From The Sunday Times, 18th October 1970 [link]
Tom, Dick and Harry took a test in each of five subjects. Each test was marked out of a total of 40. In grand total each boy obtained half-marks, and no boy scored the same mark in two or more tests.
Each boy’s best and third-best marking totalled one-fifth more than the total of his best and fourth-best, and each boy’s worst mark exceeded 10.
The aggregate of the three boys’ marks in each of four subjects was the same, the highest single mark going to Tom. The second-highest was scored by Dick in the remaining subject.
How many marks did Harry get in that subject?
This puzzle is included in the book Sunday Times Brain Teasers (1974).
[teaser490]
Jim Randell 11:58 am on 30 July 2019 Permalink |
This Python program runs in 410ms.
Run: [ @repl.it ]
from enigma import (irange, subsets, multiset, cproduct, printf) # find sets of 5 scores that sum to 100 ss = list() for s in subsets(irange(11, 40), size=5, select='C'): # total score is 100 if not (sum(s) == 100): continue # (best + 3rd best) = (6/5)(best + 4th best) if not (5 * (s[-1] + s[-3]) == 6 * (s[-1] + s[-4])): continue ss.append(s) # choose scores for the 3 students for (s1, x2, x3) in subsets(ss, size=3, select='C'): # choose orders for s2 and s3 permute = lambda x: subsets(x, size=len, select='P') for (s2, s3) in cproduct([permute(x2), permute(x3)]): scores = (s1, s2, s3) # accumulate the total scores in each test ts = list(sum(s) for s in zip(*scores)) m = multiset(ts) if not (sorted(m.values()) == [1, 4]): continue # find the highest and second highest marks ms = sorted(s1 + s2 + s3) (m1, m2, m3) = (ms[-1], ms[-2], ms[-3]) if not (m1 > m2 > m3): continue # determine which is Tom, Dick T = D = H = -1 for (i, s) in enumerate(scores): if m1 in s: T = i if m2 in s: D = i # Harry is the other one H = 3 - (T + D) if not (sorted([T, D, H]) == [0, 1, 2]): continue # check the 2nd highest score is in the test with the unique total d = scores[D].index(m2) if not (m[ts[d]] == 1): continue # output solution printf("T = {T}", T=scores[T]) printf("D = {D}", D=scores[D]) printf("H = {H}", H=scores[H]) printf("+ = {ts}") printf("answer = {x}", x=scores[H][d]) printf()Solution: 15 marks.
The scores in each test are shown below:
The highest single mark is highlighted red. The second highest mark is orange. And the answer (Harry’s mark in the same subject as the second highest mark) is yellow.
There is a “near miss” scenario, where the scores are as follows:
The sum of the scores for each test are 61, apart from the third one where they are 56.
Tom has the highest score (33) and Dick has the second highest (26), but the score of 26 is not in the subject with a sum of 56.
The scores are a rearrangement of the scores in the actual solution because there are only three possible sequences of 5 scores between 11 and 40 that sum to 100 and have best and third best scores summing to one fifth more than the sum of the best and fourth best scores.
LikeLike