Brain-Teaser 16: [Army number]
From The Sunday Times, 18th June 1961 [link]
My army number has eight digits, the third being the same as the sixth, all the others occurring only once. The sum of the digits is 33, and the difference between the sum of the first four and the sum of last four is 3. The first four digits have irregular ascending values. When out of their correct order, three only of my last four digits have consecutive numerical value; in correct order there is a difference of at least 2 between consecutive digits. The highest digit is 7 and army numbers never start with zero.
What is my number?
This puzzle was originally published with no title.
[teaser16]
Jim Randell 10:37 am on 22 December 2020 Permalink |
Alphametically, we can consider the number to be: ABCDECFG (the 3rd and 6th digits are the same).
And we can use the [[
SubstitutedExpression]] solver from the enigma.py library to solve the puzzle.The following run file executes in 68ms. (Internal runtime of the generated program is 3.0ms).
Solution: The number is 23674605.
LikeLike
Frits 2:34 pm on 22 December 2020 Permalink |
@Jim: “When out of their correct order, three only of my last four digits have consecutive numerical value”.
You seem to have interpreted it as “at least three”.
LikeLike
Jim Randell 4:30 pm on 22 December 2020 Permalink |
@Frits: Yes, this would be a more accurate (and specific) test:
It doesn’t change the solutions found. But I’ll update my code.
LikeLike
Frits 12:59 pm on 22 December 2020 Permalink |
“three of the digits are consecutive (in some order)” could (probably) also be achieved by:
# ^ is bitwise XOR operator check = lambda li: li[2] == li[1] + 1 and \ ((li[3] == li[2] + 1) ^ (li[1] == li[0] + 1)) "check(sorted([E, C, F, G])"LikeLike