Teaser 2746: Five finger exercise
From The Sunday Times, 10th May 2015 [link] [link]
George and Martha have a five-figure code for their burglar alarm. George commented that the three-figure number formed by the first three digits of the code equalled the sum of the cubes of those first three digits.
Martha added that the three-figure number formed by the last three digits of the code equalled the sum of the factorials of those three digits. (She had to remind George what a factorial was — he remembered once she had pointed out that the factorial of 4 was 4×3×2×1 = 24).
What is their code?
This puzzle was not included in the book The Sunday Times Brain Teasers Book 1 (2019).
This completes the archive of Teaser puzzles originally published in 2015. There is a complete archive of puzzles from 2015 – present available on S2T2, as wall as many older puzzles going back to 1949.
[teaser2746]
Jim Randell 10:19 am on 20 October 2022 Permalink |
We can use the [[
SubstitutedExpression]] solver from the enigma.py library to solve this puzzle.The following run file executes in 63ms. (The internal runtime of the generated program is 424µs).
Run: [ @replit ]
Solution: The code is: 37145.
And we have:
Although not a condition of the puzzle, it turns out that the digits in the code are all different.
LikeLike
GeoffR 10:47 am on 20 October 2022 Permalink |
from itertools import permutations from enigma import factorial as fact for p1 in permutations(range(1, 10), 5): A,B,C,D,E = p1 if A**3 + B**3 + C**3 == 100*A + 10*B + C: if fact(C) + fact(D) + fact(E) == 100*C + 10*D + E: code = 10000*A + 1000*B + 100*C + 10*D + E print(f"Code is {code}.") # Code is 37145.LikeLike