Teaser 1904: Neat answer
From The Sunday Times, 14th March 1999 [link]
I have started with a four-figure number with its digits in decreasing order. I have reversed the order of the four digits to give a smaller number. I have subtracted the second from the first to give a four-figure answer, and I have seen that the answer uses the same four digits — very neat!
Substituting letters for digits, with different letters being consistently used for different digits, my answer was NEAT!
What, in letters, was the four-figure number I started with?
This puzzle is included in the book Brainteasers (2002). The puzzle text above is taken from the book.
[teaser1904]
Jim Randell 9:19 am on 29 September 2020 Permalink |
We can use the [[
SubstitutedExpression]] solver from the enigma.py library to solve this puzzle.The following run file executes in 91ms.
Run: [ @replit ]
#! python -m enigma -rr SubstitutedExpression "WXYZ - ZYXW = NEAT" "ordered(N, E, A, T) == (Z, Y, X, W)" --distinct="WXYZ,NEAT" --answer="translate({WXYZ}, str({NEAT}), 'NEAT')"Solution: The initial 4-figure number is represented by: ANTE.
So the alphametic sum is: ANTE − ETNA = NEAT.
And the corresponding digits: 7641 − 1467 = 6174.
LikeLike
Hugh Casement 1:37 pm on 29 September 2020 Permalink |
If we had not been told the digits were in decreasing order there would have been three other solutions:
2961 – 1692 = 1269, 5823 – 3285 = 2538, 9108 – 8019 = 1089.
LikeLike
Finbarr Morley 10:58 am on 24 November 2020 Permalink |
I’m not sure that’s right:
2961-1692= 1269
ANTE-ETNA=EATN
It’s true, but it’s not NEAT!
LikeLike
Jim Randell 8:57 am on 25 November 2020 Permalink |
The result of the sum is NEAT by definition.
Without the condition that digits in the number you start with are in descending order, we do indeed get 4 different solutions. Setting the result to NEAT, we find they correspond to four different alphametic expressions:
LikeLike
GeoffR 6:30 pm on 29 September 2020 Permalink |
from itertools import permutations from enigma import nreverse, nsplit for p1 in permutations((9, 8, 7, 6, 5, 4, 3, 2, 1, 0), 4): W, X, Y, Z = p1 if W > X > Y > Z: WXYZ = 1000 * W + 100 * X + 10 * Y + Z ZYXW = nreverse(WXYZ) NEAT = WXYZ - ZYXW N, E, A, T = nsplit(NEAT) # check sets of digits are the same if {W, X, Y, Z} == {N, E, A, T}: print(f"Sum is {WXYZ} - {ZYXW} = {NEAT}") # Sum is 7641 - 1467 = 6174LikeLike
GeoffR 8:56 am on 25 November 2020 Permalink |
I checked Hugh’s assertion, changing my programme to suit, and it looks as though he is correct.
My revised programme gave the original correct answer and the three extra answers, as suggested by Hugh.
@Finnbarr:
If we take NEAT = 1269, then ETAN – NATE = NEAT – (Sum is 2961 – 1692 = 1269)
from itertools import permutations from enigma import nreverse, nsplit for p1 in permutations((9, 8, 7, 6, 5, 4, 3, 2, 1,0), 4): W, X, Y, Z = p1 #if W > X > Y > Z: WXYZ = 1000 * W + 100 * X + 10 * Y + Z ZYXW = nreverse(WXYZ) NEAT = WXYZ - ZYXW if NEAT > 1000 and WXYZ > 1000 and ZYXW > 1000: N, E, A, T = nsplit(NEAT) # check sets of digits are the same if {W, X, Y, Z} == {N, E, A, T}: print(f"Sum is {WXYZ} - {ZYXW} = {NEAT}") # Sum is 9108 - 8019 = 1089 # Sum is 7641 - 1467 = 6174 << main answer # Sum is 5823 - 3285 = 2538 # Sum is 2961 - 1692 = 1269LikeLike
Finbarr Morley 9:41 am on 30 November 2020 Permalink |
A maths student would view this as 4 unknowns (A,N,T, & E) and 4 Equations.
So it can be uniquely solved with simultaneous equations.
And there’s a neat ‘trick’ recognising the pairs of letters:
A E
E A
And
N T
T N
The ANSWER is the easy bit:
ANTE
7641
The SOLUTION is as follows:
Column 4321 ANTE - ETNA = NEATFrom the 1,000’s column 4 we seen that A>E, otherwise the answer would be negative.
∴ in the 1’s column, (where E is less than A) E must borrow 1 from the T in the 10’s column:
Col. 2 1 T-1 10+E N A A TThere are 2 scenarios:
(A) N>T
(B) N<T
As before, T in the 10’s column must borrow 1 from the N in the 100’s column.
4 3 2 1 A N-1 10+T-1 10+E - E T N A = N E A TThe equations for each of the 4 columns are:
Rearrange to:
From here either solve by substituting numbers, or with algebra.
SUBSTITUTION:
A+E=8 and A>E. So A = 5,6,7 or 8
ALGERBRA:
N+T=10 A+E=8 (2)-(N-T=9-A) (1)+(A-E=10-T) 2T=1+A 2A =(18-T) (x2) 4T=2+(2A) ∴ 4T=2+(18-T) 5T=20 T=4 ∴ N=6 (N+T=10) ∴ E=1 (N-T=1+E) ∴ A=7 (A+E=8)Check assumption (A) N>T TRUE (6>4)
LikeLike
Finbarr Morley 9:43 am on 30 November 2020 Permalink |
Now repeat for Assumption (B) N < T, to see if it is valid.
Equations are similar but different:
This time the N in the 100’s column must borrow 1 from the A in the 1000’s column.
The equations for each of the 4 columns are:
Rearrange to:
From here either solve by substituting numbers, or with algebra.
SUBSTITUTION:
A+E=9 and A>E.
So A = 5,6,7 or 8 or 9
There are no valid answers with N<T.
ALGEBRA:
T+N = 9 A+E = 9 2) +T-N = A+1 1) +(A-E = 10-T) 2T = 10+A 2A = 19-T x2) 4T = 20+2A ∴ 4T = 20+19-T 3T = 39 T = 13Since this is not 0 to 9, the assumption (B) N<T is invalid.
Assumption A is the only valid solution.
There can be only one – William Shakespeare
LikeLike
Jim Randell 11:55 am on 30 November 2020 Permalink |
@Finbarr: Thanks for your comments. (And I hope I’ve tidied them up OK).
Although I think we can take a bit of a shortcut:
If we start with:
Then considering the columns of the sum we have:
Then, (units) + (1000s) and (10s) + (100s) give:
which could be used to shorten your solution.
LikeLike
Jim Randell 1:53 pm on 30 November 2020 Permalink |
Or we can extend it into a full solution by case analysis:
Firstly, we see Z ≠ 0, as ZYXW is a 4-digit number.
And W > 5, as 5 + 4 + 3 + 2 < 18.
So considering possible values for W:
[W = 6]
There is only one possible descending sequence that sums to 18, i.e. (6, 5, 4, 3)
So the sum is:
which doesn’t work.
[W = 7]
W must be paired with 3 (to make 10) or 1 (to make 8).
If it is paired with 3, then the other pair is 2+6. So the sum is:
which doesn’t work.
If it is paired with 1, then the other pair is either 2+8 or 4+6, which gives us the following sums:
The first doesn’t work, but the second gives a viable solution: ANTE − ETNA = NEAT.
And the following cases show uniqueness:
[W = 8]
W must be paired with 2, and the other pair is either 1+7 or 3+5, and we have already looked at (8, 7, 2, 1)
This doesn’t work.
[W = 9]
W must be paired with 1, and the other pair either 2+6 or 3+5:
Neither of these work.
LikeLike
Finbarr Morley 3:14 pm on 30 November 2020 Permalink |
I’m curious about the properties of these Cryptarithmetics.
How is it that ANTE-ETNA=NEAT has 1 unique solution out of 10,000.
But ANTE-ETNA=NAET has none?
A Google search reveals some discussion:
http://cryptarithms.awardspace.us/primer.html
https://www.codeproject.com/Articles/176768/Cryptarithmetic
https://onlinelibrary.wiley.com/doi/abs/10.1111/j.1949-8594.1987.tb11711.x
The latter seems to be heading for a discussion on the rules, but it’s ony the first page of an extract.
Any thoughts from the collective on what the natural rules are?
LikeLike