Teaser 1929: Square trip
From The Sunday Times, 5th September 1999 [link]
My car has an odometer, which measures the total miles travelled. It has a five-figure display (plus two decimal places). There is also a “trip” counter with a three-figure display.
One Sunday morning, when the car was nearly new, the odometer showed a whole number which was a perfect square and I set the trip counter to zero. At the end of that day the odometer again showed a whole number that was a perfect square, and the trip counter showed an odd square.
Some days later, the display on the odometer was four times the square which had been displayed on that Sunday evening, and once again both displays were squares.
What were the displays on that last occasion?
This puzzle is included in the book Brainteasers (2002). The puzzle text above is taken from the book.
[teaser1929]
Jim Randell 10:55 am on 3 November 2020 Permalink |
I supposed that the initial reading was less than 1000 miles, and the car travels less than 1000 miles on the particular Sunday.
This Python program runs in 49ms.
Run: [ @repl.it ]
from enigma import irange, inf, is_square, printf def solve(): # consider initial readings (when the car was nearly new) for a in irange(1, 31): r1 = a * a # at the end of the day for b in irange(a + 1, inf): r2 = b * b # the trip reading is an odd square t2 = r2 - r1 if t2 > 1000: break if not(t2 % 2 == 1 and is_square(t2)): continue # some days later the odometer reads 4 times as far r3 = 4 * r2 # and the trip reading is also a square t3 = (r3 - r1) % 1000 if not is_square(t3): continue yield ((r1, 0), (r2, t2), (r3, t3)) # find the first solution for ((r1, t1), (r2, t2), (r3, t3)) in solve(): printf("{r1} + {t1}; {r2} + {t2}; {r3} + {t3}") breakSolution: The displays were 2500, and 100.
The trip was set to zero when the car had done 400 miles (= 20²), so it was still fairly new.
Then after another 225 miles, the odometer would read 625 miles (= 25²), and the trip would read 225 (= 15²).
The final reading was taken after another 1875 miles. The odometer reads 2500 miles (= 50²), and the trip reads the 3 least significant digits of 2100, which are 100 (= 10²).
LikeLike
Jim Randell 2:19 pm on 3 November 2020 Permalink |
As r1, r2, t2 are all squares, such that: r1 + t2 = r2 we can solve this puzzle using Pythagorean triples.
Run: [ @repl.it ]
from enigma import pythagorean_triples, is_square, printf # consider pythagorean triples for (x, y, z) in pythagorean_triples(100): # readings (r1, t1) = (y * y, 0) (r2, t2) = (z * z, x * x) if not(r1 < 1000 and t2 < 1000 and t2 % 2 == 1): continue r3 = 4 * r2 t3 = (r3 - r1) % 1000 if not is_square(t3): continue # output solution printf("{r1} + {t1}; {r2} + {t2}; {r3} + {t3} [{x}, {y}, {z}]")And it is probably not a great surprise that there is a (3, 4, 5) triangle hiding in the solution.
LikeLike