Sunday Times Teaser 2858 – Beach Game
by Angela Newing
Published July 2 2017 (link)
Ken, Leanne, Mike, Nancy, Olive and Paul were playing on the beach. They had drawn a large circle in the sand and written their names clockwise, in that order, equally spaced around the edge of the circle. They also had a circular piece of card around which they had written the numbers 1 to 6 clockwise in order, also equally spaced. Then they spun the card in the middle of the sand circle and each child was awarded the number of points equal to the number closest to their name. They kept repeating this process and after each spin they kept a total of their scores so far. Mike was ahead after the first spin and after each of the first five spins there was a different clear leader. Then the tide came in and washed the game away.
Which child was never in the lead, and what was that child’s total after the five spins?
-
Brian Gladman permalink12345678910111213141516171819202122232425262728293031# run <rnd> rounds, giving running <scores> and <leaders>def solve(scores, rnd, leaders=[]):# if we have finishedif not rnd:# ... return this solutionyield leaders, scoreselse:# consider the possible results of this roundfor i in range(6):s = [x + y for x, y in zip(scores, ((i + x) % 6 + 1 for x in range(6)))]mxs = max(s)# which must produce a clear leaderif s.count(mxs) == 1:# find the position of the winner on this roundp = s.index(mxs)# which must be Mike on the first roundif leaders or p == 2:# each round must produce a different leaderif p not in leaders:# proceed to the next roundyield from solve(s, rnd - 1, leaders + [p])# find possible round leaders and final scoresfor leaders, scores in solve((0,) * 6, 5):# find the person who never led a round and their scoreno_win, = set(range(6)).difference(leaders)p = ('Ken', 'Leanne', 'Mike', 'Nancy', 'Olive', 'Paul')[no_win]score = scores[no_win]print(f'{p}, who was never in the lead, finished with {score}.')