Teaser 2681: Inconsequential
From The Sunday Times, 9th February 2014 [link] [link]
An “arithmetic” sequence is one in which each number is a fixed amount more than the previous one. So, for example, 10, 29, 48, … is an arithmetic sequence. In this case its ninth number is 162, which happens to be divisible by 9. I have in mind another arithmetic sequence whose ninth number is divisible by 9. This time it starts with two three-figure numbers, but in this case I have consistently replaced digits by letters, with different letters used for different digits.
The arithmetic sequence then begins ONE, TWO, …, and its ninth number is NINE.
To win, find the number to WIN.
[teaser2681]
Jim Randell 9:10 am on 27 August 2020 Permalink |
The common difference is (TWO − ONE), and there are 8 instances of the common difference between ONE and NINE.
So, we can solve this puzzle straightforwardly using the [[
SubstitutedExpression()]] solver from the enigma.py library.The following run file executes in 110ms.
Run: [ @replit ]
Solution: WIN = 523.
The progression is: ONE = 631, TWO = 956, …, NINE = 3231.
The common difference is: TWO − ONE = 325.
LikeLike
GeoffR 10:39 am on 27 August 2020 Permalink |
LikeLike
GeoffR 11:02 am on 27 August 2020 Permalink |
from itertools import permutations for Q in permutations(range(1,10), 6): O, N, E, T, W, I = Q ONE, TWO = 100*O + 10*N + E, 100*T + 10*W + O WIN = 100*W + 10*I + N NINE = 1010*N + 100*I + E if NINE == ONE + (TWO - ONE) * 8 and NINE % 9 == 0: print(f"ONE = {ONE}, TWO = {TWO}, NINE = {NINE}, WIN = {WIN}") # ONE = 631, TWO = 956, NINE = 3231, WIN = 523LikeLike
Frits 1:26 pm on 27 August 2020 Permalink |
@GeoffR, shouldn’t you allow for E, I and W to be zero as well?
LikeLike
Frits 1:20 pm on 27 August 2020 Permalink |
# elements in range <r> unequal to values of D[i] def domain(i, r): vals = set() for s in D[i]: # use globals() iso eval() vals.add(globals()[s]) return [x for x in r if x not in vals] # set up dictionary of for-loop iterator names def init(li): for i in range(1,len(li)): D[li[i]] = li[0:i] # concatenate list of integers to_num = lambda *args: int("".join(map(str, args))) D = {} init(['O','N','E','T','W']) for O in range(1,10): for N in domain('N', range(1,10)): for E in domain('E', range(0,10)): ONE = to_num(O,N,E) for T in domain('T', range(1,10)): if T > O: for W in domain('W', range(0,10)): TWO = to_num(T,W,O) unit = TWO - ONE units8 = 8*unit + ONE if units8 % 9 != 0 or units8 < 1000: continue s = str(units8) if s[3] != str(E): continue if s[0] != str(N) or s[2] != str(N): continue # check letter I if int(s[1]) in {O,N,E,T,W}: continue WIN = str(W)+s[1]+str(N) print("WIN ONE TWO NINE") print(WIN, ONE, TWO, units8) # WIN ONE TWO NINE # 523 631 956 3231LikeLike
GeoffR 1:47 pm on 27 August 2020 Permalink |
@Frits: In theory maybe, but it would not have made any difference in practice.
As the title of the teaser says – “Inconsequential” ?
LikeLike