Sunday Times Teaser 2986 – The Prhymes’ Numbers
by Stephen Hogg
Published December 15 2019 (link)
The Prhymes’ triple live album “Deified” has hidden numerical “tricks” in the cover notes. Track 1, with the shortest duration, is a one-and-a-half minute introduction of the band, shown as “1. Zak, Bob, Kaz 1:30” in the cover notes. The other nineteen tracks each have different durations under ten minutes and are listed similarly with durations in “m:ss” format.
For each of tracks 2 to 20, thinking of its “m:ss” duration as a three-figure whole number (ignoring the colon), the track number and duration value each have the same number of factors. Curiously, the most possible are palindromic; and the most possible are even.
What is the total album duration (given as m:ss)?
-
Brian Gladman permalink123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657from collections import defaultdictfrom itertools import productfrom number_theory import tau# we need to collect both track numbers and track durations# based on the number of factors (i.e. divisors) they have# the set of the number of factors in the numbers 1..20n_fac = set()# collect track numbers against their numbers of factorsnf2tns = defaultdict(set)for t in range(2, 21):n = tau(t)n_fac.add(n)nf2tns[n].add(t)# collect track durations against their numbers of factors, collecting# those that are even palindromes, odd palindromes, even non-palindromes# and odd non-palindromesd = defaultdict(lambda: defaultdict(set))# track duration minutes and secondsfor m, ss in product(range(1, 10), range(60)):# the minimum duration is 1:30if (mss := 100 * m + ss) > 130:# the number of factors in the durationnf = tau(mss)if nf in n_fac:d[nf][2 * (m != ss % 10) + (ss & 1)].add(mss)# track 1 has one factor but 1:30 has eight factors so# it does not obey the rules so we have to add it heretp, tns = {130}, set(range(2, 21))# assemble the set of durations for all numbers of factorsfor nf in n_fac:# the number of durations we needn_tr = len(nf2tns[nf])tns.difference_update(nf2tns[nf])# make this number by using durations for each number of factors# by picking from the available sets in the order even palindromes,# odd palindromes, even non-palindromes and odd non-palindromesfor i in range(4):dp = d[nf][i]lr = n_tr - len(dp)if lr >= 0:tp |= dpn_tr = lrelif n_tr:tp.union(sorted(dp)[:n_tr])breakassert not tns# find the total album durationm, ss = divmod(sum(60 * (mss // 100) + mss % 100 for mss in tp), 60)durs = ' '.join(sorted(f"{mss // 100}:{mss % 100:02d}" for mss in tp))print(f"The total album duration is {m}:{ss:02d} ({durs}).")