Sunday Times Teaser 2748 – I Go Up and Up
by Victor Bryant
Published: 24 May 2015 (link)
I have in mind an arithmetic progression; ie, a sequence which goes up and up by a fixed amount (such as 1, 10, 19, 28, …) and — as in that example — one of the terms of my progression will eventually be 10000. But I have coded the numbers by consistently replacing digits by letters and in this way the arithmetic progression has become
     I,   GO,   UP,   AND,   …
To win a few pounds, please send in the number POUND.
2 Comments
Leave one →
-
Brian Gladman permalink1234567891011121314151617181920212223# I is a single digit numberfor I in range(10):# UP has two digitsfor up in range(10, 100):# check that GO is a two digit integergo, r = divmod(I + up, 2)# and that the sequence includes 10000if r == 0 and go > 9 and not (10000 - I) % (go - I):# compute the sequence increment and the letter's digitsinc, (U, P), (G, O) = go - I, str(up), str(go)s1 = set([str(I), G, O, U, P])# check that the digits are all differentif len(s1) == 5:# extract AND and ensure that its digits are differentstr_and = str(I + 3 * inc)s2 = set(str_and)if len(str_and) == len(s2) == 3:A, N, D = str_and# ensure all the letters are different and A > 0if not (A == '0' or s1 & s2):print('POUND is {}'.format(P + O + U + N + D))
-
geoffrounce permalink123456789101112131415161718192021222324252627282930313233from itertools import permutationsfor q in permutations('1234567890',3):# find numbers I and GOi,g,o = qif i == '0' : continueif g == '0' : continueI = int(i)GO = int(g + o)q1 = set('1234567890').difference(q)# find number UPfor q2 in permutations(q1,2):u, p = q2if u == '0' : continueUP = int(u + p)# check differences are the sameif GO - I == UP - GO:q3 = q1.difference(q2)# find number ANDfor q4 in permutations(q3,3):a, n, d = q4if a == '0' : continueAND = int(a + n + d)# check differences are the sameif UP - GO == AND - UP:diff = UP - GOif (10000 - I) % diff == 0:POUND = int(p + o + u + n + d)print('POUND = ',POUND)