Teaser 2811: Making arrangements
From The Sunday Times, 7th August 2016 [link] [link]
Beth wrote down a three-figure number and she also listed the five other three-figure numbers that could be made using those same three digits. Then she added up the six numbers: it gave a total whose digits were all different, and none of those digits appeared in her original number.
If you knew whether her original number was prime or not, and you knew whether the sum of the three digits of her original number was prime or not, then it would be possible to work out her number.
What was it?
[teaser2811]
Jim Randell 1:47 pm on 17 August 2021 Permalink |
If the number is ABC, then in order for the different orderings of (A, B, C) to make 6 different numbers A, B, C must all be distinct and non-zero. Then we have:
We can use two of the routines from the enigma.py library to solve this puzzle. [[
SubstitutedExpression()
]] to solve the alphametic problem, and [[filter_unique()
]] to find the required unique solutions.The following Python program runs in 53ms.
Run: [ @replit ]
Solution: Beth’s number was 257.
The only values for (A, B, C) that work are (2, 5, 7) and (3, 7, 9). These can be assembled in any order to give an original number that works.
Of these 257 is the only arrangement that gives a prime number, with a digit sum that is not prime.
LikeLike
GeoffR 9:39 am on 18 August 2021 Permalink |
I used four lists for the two primality tests for each potential 3-digit answer. The list with a single entry was Beth’s number.
LikeLike
Frits 3:02 pm on 18 August 2021 Permalink |
LikeLike
GeoffR 3:08 pm on 19 August 2021 Permalink |
An easy solution with standard MiniZinc, although the answer needs to be interpreted from multiple output configuration.
LikeLike