Teaser 2597: Ages ago
From The Sunday Times, 1st July 2012 [link] [link]
Bert’s age in years is one less than one-and-a-half times the age Alf was a whole number of years ago. Cal’s age in years is one less than one-and-a-half times the age Bert was, the same number of years ago.
Dave’s age in years is one less than one-and-a-half times the age Cal was, again the same number of years ago. All four ages are different two-figure numbers, Cal’s age being Bert’s age with the order of the digits reversed.
What (in alphabetical order) are their ages?
[teaser2597]







Jim Randell 7:45 am on 31 October 2024 Permalink |
Here’s a solution using the [[
SubstitutedExpression]] solver from the enigma.py library.The following run file executes in 75ms. (Internal runtime of the generated program is 956µs).
Solution: The ages now are: Alf = 98; Bert = 86; Cal = 68; Dave = 41.
And Cal’s age is the reverse of Bert’s.
40 years ago, Alf was 58. And 1.5× this age is 87, and Bert’s current age is one less than this.
40 years ago, Bert was 46. And 1.5× this age is 69, and Cal’s current age is one less than this.
40 years ago, Cal was 28. And 1.5× this age is 42, and Dave’s current age is one less than this.
LikeLike
Ruud 8:38 am on 31 October 2024 Permalink |
Brute force:
import itertools for a, b, d in itertools.permutations(range(10, 100), 3): c = int(str(b)[::-1]) if b != c and c >= 10: for n in range(1, min(a, b, c, d) + 1): if b == (a - n) * 1.5 - 1: if c == (b - n) * 1.5 - 1: if d == (c - n) * 1.5 - 1: print(f"Alf={a} Bert={b} Cal={c} Dave={d} Number of years ago={n}")LikeLiked by 1 person
ruudvanderham 9:26 am on 31 October 2024 Permalink |
Quite different and much more efficient than my previous one:
for a in range(10, 100): for n in range(a): b = (a - n) * 1.5 - 1 c = (b - n) * 1.5 - 1 d = (c - n) * 1.5 - 1 if all(x == round(x) and n < x < 100 for x in (b, c, d)): if len({a, b, c, d}) == 4: if str(round(b)) == str(round(c))[::-1]: print(a, b, c, d, n)LikeLike
GeoffR 9:35 am on 1 November 2024 Permalink |
LikeLike