Brain-Teaser 41: Selecting a team
From The Sunday Times, 31st December 1961 [link]
The Cricket Selection Committee of the State of Bonga have chosen 13 players — six batsman, five bowlers, an all-rounder and a wicketkeeper — for their Test Match against Donga, the final choice on the day of the match being left to the captain.
The captain decides that the two to be omitted must be a batsman and a bowler, a batsman and the all-rounder, or a bowler and the all-rounder: but, distrusting his judgment of individuals, he consults the Chief Magician, who surprisingly assures him that if the ages of the eleven total 282, the team will be invincible.
A check of the players’ ages shows that three (two bowlers and the all-rounder) are aged 24: the ages of the remainder are all different, ranging from 21 to 31, the captain, aged 31, being the oldest. The ages of the three remaining bowlers total 83.
The captain discovers that there is only one possible choice which will comply with the Magician’s advice, and is relieved to find that he is not under the necessity of standing down himself.
What is the wicketkeeper’s age?
[teaser41]
Jim Randell 8:47 am on 25 July 2021 Permalink |
There are 3 players who are 24, and 1 of each of the other ages from 21 to 31.
So, the total for all 13 players being 334.
We are looking to select 11 players with a total of 282. So we need to discard 2 players, whose ages sum to 52.
This Python program runs in 51ms.
Run: [ @replit ]
from itertools import product from enigma import irange, diff, subsets, join, printf # the squad is: # [A] 1 all-rounder (24) # [BCDEF] 5 bowlers, 2 @ (24), remaining 3 have combined age of 83 # [GHIJKL] 6 batsmen # [W] 1 wicket keeper allrs = 'A' bowls = 'BCDEF' bats = 'GHIJKL' # unallocated ages = 21 - 31, except 24 ages = diff(irange(21, 31), [24]) # choose the ages of the 3 bowlers that sum to 83 for bs in subsets(ages, size=3, fn=list): if sum(bs) != 83: continue # choose the age of the wicket keeper for wk in ages: if wk in bs: continue # map names to ages m = dict(A=24, B=24, C=24, W=wk) m.update(zip(diff(bowls, m.keys()), bs)) # remaining bowlers m.update(zip(bats, diff(ages, bs + [wk]))) # batsmen # look for excluded combinations that add up to 334 - 282 = 52 exclude = lambda xs, ys: list((x, y) for (x, y) in product(xs, ys) if m[x] + m[y] == 52) xs = exclude(bats, bowls) + exclude(bats, allrs) + exclude(bowls, allrs) # there is only one possible set of excluded players if len(xs) == 1: xs = xs[0] # and they don't include the captain (age = 31) if any(m[x] == 31 for x in xs): continue # output solution printf("wk = {wk} [excluded = {xs}]", xs=join(sorted(xs), sep=" "))Solution: The wicket-keeper is 23.
A bowler (28) and the all-rounder (24) are dropped from the team.
The ages of squad are:
LikeLike