Teaser 2659: Two by two
From The Sunday Times, 8th September 2013 [link] [link]
I have given each letter of the alphabet a different value from 0 to 25, so some letters represent a single digit and some represent two digits.
Therefore, for example, a three-letter word could represent a number of three, four, five or six digits. With my values it turns out that:
TWO × TWO = FOUR
Another “obvious” fact that I can tell you is that every digit occurring in TWO is a prime!
What is the number FOUR?
Interestingly, one of the earliest published alphametic puzzles was:
TWO × TWO = THREE
(using more usual alphametic rules), which appeared almost 100 years ago in the July 1924 issue of Strand Magazine.
[teaser2659]
Jim Randell 11:31 am on 8 February 2024 Permalink |
Here is a solution using the [[
SubstitutedExpression]] solver from the enigma.py library (although the method of constructing alphametic words is different from the usual alphametic rules).It runs in 194ms. (Internal runtime of the generated program is 78ms).
Run: [ @replit ]
Solution: FOUR = 105625.
We have:
And the solution to the TWO × TWO = THREE puzzle is:
LikeLike
GeoffR 4:04 pm on 8 February 2024 Permalink |
from enigma import all_different from math import isqrt def is_sq(x): return isqrt(x) ** 2 == x tup_TWO = (2, 3, 5, 7, 22, 23, 25) for F in range(1, 26): for O in tup_TWO: if O == F:continue for U in range(26): if U in (F, O):continue for R in (4, 9, 25): # max value of R = 25 if R in (U, O, F):continue FOUR = int(str(F) + str(O) + str(U) + str(R)) if not is_sq(FOUR):continue for T in tup_TWO: for W in tup_TWO: if not all_different(T, W, O, F, U, R):continue TWO = int(str(T) + str(W) + str(O)) if TWO * TWO == FOUR: print(f"TWO = {TWO}, FOUR = {FOUR}.") # TWO = 325, FOUR = 105625.LikeLike
GeoffR 8:55 pm on 8 February 2024 Permalink |
TWO × TWO = THREE is much easier than TWO × TWO = FOUR, as the former has only digits 0..9 to consider.
from itertools import permutations for p1 in permutations('1234567890', 3): T, W, O = p1 if T == '0':continue TWO = int(T + W + O) q1 = set('01234560789').difference([T, W, O]) for p2 in permutations(q1, 3): R, H, E = p2 THREE = int(T + H + R + E + E) if TWO * TWO == THREE: print(f"Sum: {TWO} * {TWO} = {THREE}.") # Sum: 138 * 138 = 19044.LikeLike