Teaser 3101: Lap progression
From The Sunday Times, 27th February 2022 [link] [link]
In a charity fundraising drive, two friends completed laps of their local track. Alan, a cyclist, raised £1 for his first lap, £2 for the second, £3 for the third and so on, with each extra lap earning £1 more than the prior. Bob, who walks, raised £1 for his first lap, £2 for the second, £4 for the third and so on, with each extra lap earning double the prior. Starting together, they travelled at constant speeds, and finished their last lap simultaneously.
After they had added up their totals, they were surprised to find they each raised an identical four-figure sum.
Including the beginning and end of their drive, how many times did Alan and Bob cross the lap start-finish line together?
[teaser3101]
Jim Randell 5:28 pm on 25 February 2022 Permalink |
We are looking for 4-digit numbers that are both triangular and one less than a power of 2.
This Python program runs in 46ms.
Run: [ @replit ]
from enigma import (irange, inf, is_triangular, gcd, printf) # consider powers of 2 p = 1 for n in irange(1, inf): p *= 2 t = p - 1 # we are looking for a 4-digit total if t < 1000: continue if t > 9999: break # that is also triangular r = is_triangular(t) if r is None: continue # calculate number of coincident boundaries g = gcd(n, r) + 1 printf("{t} = 2^({n})-1 = T[{r}] -> {g} times")Solution: Alan and Bob were together at the start/finish line 7 times.
Manually:
There are only four 4-digit numbers that are 1 less than a power of 2:
The triangular root of a number is given by trirt(x) = (√(8x + 1) − 1) / 2, and can be easily calculated for these 4 numbers:
Hence the solution occurs when Bob completes 12 laps and Alan 90 laps.
We can then calculate the number of times they are at the start/finish together:
The puzzle also works (but with a different answer) if Bob’s progression is the odd numbers, 1, 3, 5, 7, 9, ….
LikeLike
GeoffR 12:22 pm on 2 March 2022 Permalink |
% A Solution in MiniZinc include "globals.mzn"; % Four figure sums for Alan and Bob var 1000..9999:A; var 1000..9999:B; var 45..140:a; % triangular number range var 10..13:b; % power of 2 range var 1..13:laps; % times crossing start/finish line together constraint A == a * (a + 1) div 2 ; constraint B = pow(2, b) - 1 ; constraint A == B; % reusing Hakan's GCD Function function var int: gcd(var int: x, var int: y) = let { int: p = min(ub(x),ub(y)); var 1..p: g; constraint exists(i in 1..p) ( x mod i = 0 /\ y mod i = 0 /\ forall(j in i+1..p) ( not(x mod j = 0 /\ y mod j = 0) ) /\ g = i); } in g; % Times Alan and Bob cross the lap start-finish line together constraint laps == gcd(a, b) + 1; solve satisfy; output ["No. of coincident start/finish crossings = " ++ show(laps)];LikeLiked by 1 person