Sunday Times Teaser 2916 – Pointless Batting Averages
by Susan Bricket
Published August 12 2018 (link)
When my son was chosen to play cricket for his School First XI, I kept a record of the number of runs he scored in each of his first five innings. After each innings I calculated his batting average (the total number of runs scored so far divided by the number of innings) and found an interesting pattern:
(i) Each score was under 30
(ii) They were all different
(ii) Each of the five averages was a whole number
When he asked me how he could maintain this pattern with his sixth innings, I was able to tell him the smallest score that would achieve this.
What is the largest number this could have been?
One Comment
Leave one →
-
Brian Gladman permalink123456789101112131415161718192021222324252627282930313233343536373839404142# find a set of scores (scrs) over (n) innings such that# the scores are all different and the cumulative batting# averages after each innings (avgs) are all differentdef solve(n, i=0, scrs=tuple(), avgs=tuple()):# have we finished?if i == n:yield scrs, avgselse:# consider the possible scores in the next inningsfor s in range(30):# form the next cumulative batting averageav, r = divmod((i * avgs[-1] if i else 0) + s, i + 1)# if it is integer and the score hasn't occurred beforeif not r and s not in scrs:# proceed to the next inningsyield from solve(n, i + 1, scrs + (s,), avgs + (av,))# for storing the solutions6x, sc, av, cnt = 0, 0, 0, 0# consider possible scores over five inningsfor scrs, avgs in solve(5):# collect solutions for a sixth innings# meeting the same contraintst = -sum(scrs) % 6s6v = [x for x in range(30) if x % 6 == t and x not in scrs]# consider the minimum score that gives a# solution and find the five innings solution# for which this minimum value is a maximumif s6v and s6v[0] >= s6x:# do we have a new maximum?if s6v[0] > s6x:s6x = s6v[0]cnt = 0# otherwise print a solution for the current maximumcnt += 1sc = scrs + (s6x,)av = avgs + ((5 * avgs[-1] + s6x) // 6,)print(f'{s6x}({cnt}): scores: {sc}, averages: {av}.')print(f'Answer: {s6x}')