Teaser 2614: The end of time
From The Sunday Times, 28th October 2012 [link] [link]
In the table the letters represent the numbers 1 to 25 in some order. In each row, each column and each main diagonal the sum of the five numbers is the same. If you list all the letters in increasing numerical order then somewhere in the list you will get …, S, U, N, D, A, Y, T, I, M,.. with E coming later.
Which letters are equal to 11, 9, 7, 3, 23 and 22?
[teaser2614]

Jim Randell 9:02 am on 2 April 2024 Permalink |
The total of the numbers from 1 to 25 is 325. So the magic constant is 325/5 = 65.
We can solve the puzzle using the [[
SubstitutedExpression]] solver from the enigma.py library.The following run file executes in 91ms. (Internal runtime of the generated program is 4.1ms).
Run: [ @replit ]
And here is a wrapper that assembles the required answer(!).
from enigma import (SubstitutedExpression, rev, join, printf) # load the alphametic puzzle p = SubstitutedExpression.from_file("teaser2614.run") # solve it for s in p.solve(verbose=0): r = rev(s) # output solution vs = [11, 9, 7, 3, 23, 22] printf("{vs} -> {ks}", ks=join(r[v] for v in vs))Solution: The given values spell: ANSWER.
The grid looks like this:
And the letters ordered by value are:
LikeLike
Frits 10:59 am on 2 April 2024 Permalink |
@Jim, 5th column equation is same as 5th row equation.
LikeLike
Jim Randell 11:13 am on 2 April 2024 Permalink |
Thanks. Fixed now.
I did make a version of the code that derives the expressions from the rows of the square [@replit] (which eliminates mistakes like this), but I posted the literal version as it is more readable.
LikeLike
GeoffR 2:22 pm on 2 April 2024 Permalink |
LikeLike
Frits 6:09 pm on 3 April 2024 Permalink |
# make sure loop variable value is not equal to previous ones def domain(v, r=range(1, 26)): # find already used loop values ... vals = set() # ... by accessing previously set loop variable names i = 0 # initially <i> (otherwise compiler error) for i, s in enumerate(lvd[v], 1): val = globals()[s] # general domain check if not (0 < val < 26): return [] vals.add(val) # don't except duplicates in previous variables if len(vals) != i: return [] return [x for x in r if x not in vals] # set up dictionary of for-loop variables lv = list("NXSUDAYTIMGEQVWBCLOKJFHPR") lvd = {v: lv[:i] for i, v in enumerate(lv)} # D + I + N + S = (N + 1) + (N + 5) + N + (N - 2) = 4N + 4 --> X = 61 - 4N for N in domain('N', range(9, 16)): X = 61 - 4 * N S, U, N, D, A, Y, T, I, M = [N + x for x in range(-2, 7)] G = 65 - (A + M + S + Y) # E + I + M + Q + U = 65, E = 65 - Q - (I + M + U) and E > M # assume E = M + x, x > 0 --> x = 65 - Q - (I + 2M + U) > 0 if (I + 2 * M + U) > 63: continue # check rest of numbers for E in domain('E', range(M + 1, 26)): Q = 65 - (E + I + M + U) for V in domain('V'): W = 65 - (U + V + X + Y) for B in domain('B'): C = 65 - (A + B + D + E) L = 65 - (B + G + Q + V) for O in domain('O'): K = 65 - (L + M + N + O) J = 65 - (E + O + T + Y) for F in domain('F'): H = 65 - (F + G + I + J) P = 65 - (A + F + K + U) for R in domain('R'): if R != 65 - (P + Q + S + T): continue # check remaining equations to be sure we give a correct answer if P + Q + R + S + T != 65: continue if C + H + M + R + W != 65: continue vs = [11, 9, 7, 3, 23, 22] nums = [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y] chars = "ABCDEFGHIJKLMNOPQRSTUVWXY" print(f"answer: {[chars[nums.index(v)] for v in vs]}")LikeLike
Frits 8:39 pm on 3 April 2024 Permalink |
line 30 also implies that N is less than 12.
LikeLike