Sunday Times Teaser 2723 – St. Andrews Day
by Andrew Skidmore
In this sum different letters represent different digits:
S A I N T
A N D R E W
——————————–
3 0 1 1 1 4
——————————–
What is SEND?
One Comment
Leave one →
-
brian gladman permalink1234567891011121314151617181920from itertools import permutations# by inspection A must be either 2 or 3for A in (2, 3):# permute the remaining eight digitssd = set(range(10)) - set((A,))for p in permutations(sd, 8):D, E, I, N, R, S, T, W = p# leading digits cannot be zero and since both I and R and T and W# are intercahageable we can choose their orderif A and S and I < R and T < W:saint = 10000 * S + 1000 * A + 100 * I + 10 * N + Tandrew = 100000 * A + 10000 * N + 1000 * D + 100 * R + 10 * E + W# check that the sum is correctif saint + andrew == 301114:send = 1000 * S + 100 * E + 10 * N + Dfs = 'SEND = {} (SAINT = {}, ANDREW = {}).'print(fs.format(send, saint, andrew))