Teaser 2630: River crossing
From The Sunday Times, 17th February 2013 [link] [link]
Two lads walking together had to get back to their tent which was a short distance south-east of them. However, it involved crossing a river which was running from west to east and was a constant five metres wide. Whichever route they chose, they made sure that they were in the water for the shortest distance possible.
One lad took the obvious such route and went due south and then due east, but the other took the shortest possible such route, thus cutting his friend’s distance by a quarter.
What was the length of that shortest route?
[teaser2630]







Jim Randell 8:38 am on 18 May 2023 Permalink |
See also: Teaser 3103.
They both cross the river at right angles to give a river crossing of 5m.
We can then remove the river, and the remaining (walking) paths are the sides of a right-angled triangle. The optimal route being the hypotenuse, and the first lad traversing the other two sides.
So if the triangle has sides (x, y, z), the total length of the first path (including river crossing) is: (x + y + 5) and the total length of the second (optimal) path is (z + 5).
And so:
In order to get a unique solution to the puzzle we need to assume that the tent is exactly SE of the lads (i.e. on a bearing of 135°).
Then the first lad travels the same total distance on the south leg of his journey (= x + 5) as he does on the east leg (= y).
So we have:
and:
So the optimal distance is z + 5 = 30m.
Solution: The shortest route is 30m.
And the first lad’s distance is 40m.
We can solve the quadratic equation using the [[
Polynomial()]] class from the enigma.py library:Run: [ @replit ]
from enigma import (Polynomial, sq, printf) # construct the polynomial (quadratic) px = Polynomial([0, 1]) py = px + 5 pz = (3 * px + 5) * 0.5 p = sq(px) + sq(py) - sq(pz) printf("[p = {p}]") # find (real, positive) roots for x in p.quadratic_roots(domain='F', include='+'): (y, z) = (py(x), pz(x)) printf("x={x:g} y={y:g} z={z:g} -> A={A:g} B={B:g}", A=x + y + 5, B=z + 5)Or we can solve the problem numerically, using the [[
find_value()]] solver from the enigma.py library:Run: [ @replit ]
from enigma import (find_value, hypot, fdiv, printf) # A's distance A = lambda x: 2 * (x + 5) # B's distance B = lambda x: hypot(x, x + 5) + 5 # find a value where B/A = 3/4 f = lambda x: fdiv(B(x), A(x)) r = find_value(f, 0.75, 0, 1000) x = r.v (a, b) = (A(x), B(x)) printf("B={b:g} A={a:g} -> B/A={f:g}", f=r.fv)If we had been told that the total distances travelled were whole numbers of metres, then we could look for appropriate right-angled triangles:
Run: [ @replit ]
from enigma import (pythagorean_triples, printf) for (x, y, z) in pythagorean_triples(995, primitive=0): if 4 * z + 5 == 3 * (x + y) and y == x + 5: printf("A={A} B={B} [x={x} y={y} z={z}]", A=x + y + 5, B=z + 5)The triangle we are looking for is a (15, 20, 25) triangle = 5× (3, 4, 5).
Removing the [[
y == x + 5]] condition at line 4 allows us to find further (integer) solutions, where the tent is south and east of the starting position, but not on a bearing of 135°.LikeLike