Teaser 2781: Number time
From The Sunday Times, 10th January 2016 [link] [link]
I have written down some numbers and then consistently replaced digits by capital letters, with different letters used for different digits. In this way my numbers have become:
TRIPLE (which is a multiple of three)
EIGHT (which is a cube)
NINE (which is divisible by nine)
PRIME (which is a prime)What is the number TIME?
[teaser2781]
Jim Randell 9:08 am on 23 March 2021 Permalink |
We can use the [[
SubstitutedExpression]] solver from the enigma.py library to solve this puzzle directly.The following run file executes in 122ms.
Run: [ @replit ]
Solution: TIME = 3901.
There are 4 solutions to the alphametic expressions, but the value for TIME is the same in all of them.
LikeLike
Frits 12:39 pm on 23 March 2021 Permalink |
With a complicated formula for N.
from enigma import is_prime alldiff = lambda seq: len(seq) == len(set(seq)) # EIGHT is a cube for i in range(22, 47): s3 = str(i ** 3) E = int(s3[0]) I = int(s3[1]) T = int(s3[-1]) if T == 0: continue if E % 2 == 0: continue # E may not be even (due to PRIME) if not alldiff(s3): continue # NINE is a multiple of 9 # sumIE plus 2*N must be equal to k*9 (k is 1,2 or 3) sumIE = I + E N = (9 + 18 * (sumIE > 9) - sumIE) // 2 if sumIE % 2 else (18 - sumIE) // 2 if N == 0 or not alldiff(s3 + str(N)): continue # TRIPLE is a multiple of 3 LMPR = [x for x in range(10) if str(x) not in s3 + str(N)] candsM = [x for x in LMPR if (sumIE + T + sum(LMPR) - x) % 3 == 0] for M in candsM: LPR = [x for x in LMPR if x != M] for L in LPR: # PRIME may not be a multiple of 3 if (sumIE + M + sum(LPR) - L) % 3 == 0: continue PR = [x for x in LPR if x != L] # consider permutations of PR for (P, R) in zip(PR, PR[::-1]): if P == 0: continue PRIME = 10000*P + 1000*R + 100*I + 10*M + E if not is_prime(PRIME): continue print(f"TIME={T}{I}{M}{E}")LikeLike