NEW = YEAR and OLD = 3A + 2(U + N + C) + Q + I + T + E + S + H gives us 71 < OLD < 75 and 17 < NEW < 57 Thus by trial and error we get: N = 3, E = 11, W = 23, Y = 12, A = 5, R = 9, O = 22, L = 25, D = 26, U = 1, C = 2, Q = 4, I = 6, T = 7, S = 8, H = 10. Happy New Year with full of health and happiness!

]]>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
from itertools import combinations, permutations # the given assignments A, B = 5, 24 # the initial assigned values ltrs_0 = set((A, B)) # We can show that 71 <= OLD <= 74 so the minimum for any # of O, L and D is 71 - 25 - 26 = 20. We don't care which # value is assigned to which letter so use combinations for c1 in combinations((20, 21, 22, 23, 25, 26), 3): OLD = sum(c1) if not 71 <= OLD <= 74: continue # the digit reversed value of OLD rev = 10 * (OLD % 10) + OLD // 10 O, L, D = c1 ltrs_1 = ltrs_0 | set(c1) # we can show that the remaining letter values are less than # 14 and E and N have to be chosen from such values for p1 in permutations(set(range(1, 14)) - ltrs_1, 2): N, E = p1 ltrs_2 = ltrs_1 | set(p1) # the order of the values for C and U doesn't matter for c2 in combinations(set(range(1, 14)) - ltrs_2, 2): C, U = c2 ltrs_3 = ltrs_2 | set(c2) # we can show that the maximum of C + N + U is 18 if C + N + U > 18: continue # the order of the values for H, I, Q, S and T doesn't matter for c3 in combinations(set(range(1, 14)) - ltrs_3, 5): H, I, Q, S, T = c3 # check that SHU + ACQUAINTANCE = OLD if 3 * A + 2 * sum(p1 + c2) - E + sum(c3) != OLD: continue ltrs_4 = ltrs_3 | set(c3) # find unassigned values for setting W, R and Y rest = set(range(1, 27)) - ltrs_4 W = rev - N - E if W in rest: # now assign R and Y (the order doesn't matter) for R, Y in combinations(rest - set((W,)), 2): # and check that YEAR ie equal to rev (= NEW) if Y + E + A + R == rev: print(rev, (A, B, C, D, E, H, I, L, N, O, Q, R, S, T, U, W, Y)) |