Sunday Times Teaser 2553 – The X-Factor
by Danny Roth
Published: 28 August 2011 (link)
George and Martha’s daughter entered a singing competition. The entrants were numbered from one upwards. The total number of entrants was a three- figure number and their daughter’s number was a two-figure number. The five digits used in those two numbers were all different and non-zero. Martha noted that the number of entrants was a single-digit multiple of their daughter’s number. George realised the same would be true if the two digits of their daughter’s number were reversed.
How many entrants were there?
2 Comments
Leave one →
-
Brian Gladman permalink123456789101112131415161718192021# the daughter's number (12 .. 98)for dn in range(12, 99):# and its digit reversed valuednr = 10 * (dn % 10) + dn // 10if dnr > dn:# the number of entrants is a single digit# multiple of the daughter's numberfor nbr in range(dn, 10 * dn, dn):# and is a three digit multiple of the# daughter's number when digit reversedif 102 <= nbr <= 987 and not nbr % dnr:# all five digits are non-zero and differents = str(nbr) + str(dn)if '0' not in s and len(set(s)) == 5:fs = "There were {} entrants (the daughter's number was {})."print(fs.format(nbr, dn))
-
geoffrounce permalink123456789101112131415161718192021for e in range(100, 999): # e = number of entrantsfor d in range(10, 99): # d = daughter's numbere_str, d_str = str(e), str(d)# check if zero is in two or three digit numbers# and check all five digits used are differentif '0' in e_str or '0' in d_str: continuer_str = e_str + d_strif len(set(r_str)) != 5: continue# check entrants number is a multiple of the daughter's numberq, r = divmod(e, d)if q < 10 and r == 0:dig1, dig2 = d // 10, d % 10d2 = 10 * dig2 + dig1 # daughter's reverse number# check entrants number is a multiple of the daughter's reverse numberq2, r2 = divmod(e, d2)if q2 < 10 and r2 == 0:print('Number of entrants =', e)