Teaser 3286: Water stop
From The Sunday Times, 14th September 2025 [link] [link]
Chuck and his brother live on a long straight road that runs from west to east through their ranches. Chuck’s ranch is 13 km west of his brother’s. The two brothers often go from one ranch to the other on horseback, but go via a nearby river so that their horses may be watered. The shortest route via the river consists of two straight sections, one being 11 km longer than the other. The point at which they reach the river is 6 km north of the road.
What is the total length of the route between the ranches that goes via the river?
[teaser3286]












Jim Randell 7:26 am on 14 September 2025 Permalink |
Solving a couple of simultaneous quadratic equations gives an unlikely looking answer:
Suppose the the ranches are at C and B, and the water is at W, 6 km north of a point X on the road.
(We can assume the distance BW is greater than CW, if it is not the situation is a reflection of this).
Then we have two right angled triangles:
And the required answer is the sum of the two hypotenuses (= 2x + 11).
This then gives rise to two equations:
The equations can be solved manually, but here is a program that uses a numerical solver.
This Python program runs in 69ms. (Internal runtime is 139µs).
from enigma import (hypot, find_zero, printf) # calculate values for x from each triangle fx1 = lambda y: hypot(y, 6) fx2 = lambda y: hypot(13 - y, 6) - 11 # calculate values of x from each triangle # and return the difference f = lambda y: fx1(y) - fx2(y) # find solutions when the difference is zero r = find_zero(f, -100, 100) y = r.v x = fx1(y) d = x + (x + 11) printf("d={d:.3f} [x={x:.3f} y={y:.3f}]")Solution: The total length of the route via the river is 26 km.
The river is 7.5 km from one ranch, and 18.5 km from the other. So the total journey is twice as far as following the road.
Or we can mirror the diagram (so that X is 4.5 km beyond B) to give a second scenario:
I think the puzzle text would have been less confusing if the brothers had just met for a picnic at W. Each travelling via a straight track from their respective ranch; one travelling 11 km further than the other. What was the total distance to the picnic spot travelled by the brothers?
LikeLike
Jim Randell 10:22 am on 14 September 2025 Permalink |
Or a similar approach using 2D geometry routines from enigma.py.
The following program has an internal runtime of 552µs:
from enigma import (point_dist, find_values, printf) # positions for C and B (C, B) = ((0, 0), (13, 0)) # and the river is at W = (x, 6) # calculate difference between distances CW, BW def f(x): W = (x, 6) return abs(point_dist(C, W) - point_dist(B, W)) # find solutions when the difference is 11 for r in find_values(f, 11, -100, 100): x = r.v W = (x, 6) (d1, d2) = (point_dist(C, W), point_dist(B, W)) d = d1 + d2 printf("d={d:.3f} [W=({x:.3f}, 6); d1={d1:.3f} d2={d2:.3f}]")LikeLike
Jim Randell 1:20 pm on 14 September 2025 Permalink |
And here is an exact solution, that uses the [[
Polynomial]] class from the enigma.py library, to derive a quadratic equation, which can then be solved to give the required answer.The following program has an internal runtime of 321µs.
from enigma import (Rational, Polynomial, sq, printf) Q = Rational() q12 = Q(1, 2) # q12 = 0.5 will also work # calculate area^2 of the triangle using: (1/2) base . height A2 = sq(q12 * 13 * 6) # sides of the triangle (as polynomials) (a, b, c) = (Polynomial("x"), Polynomial("x + 11"), 13) # polynomial for area^2 of the triangle using Heron's formula s = (a + b + c) * q12 p = s * (s - a) * (s - b) * (s - c) # find solutions of p(x) = A2 for positive x for x in p.roots(A2, domain='F', include='+'): # calculate total distance d = x + (x + 11) printf("d={d} [x={x}]")The program determines that the required solution is derived from the positive solution of the following quadratic equation (which it then solves):
LikeLiked by 1 person
Ruud 10:11 am on 14 September 2025 Permalink |
@Jim
I don’t know why you say that you get an unlikely answer.
The negative y just means that the point W is west of C (or east of B). And then it all fits.
I have the following solution:
import sympy as sp l = sp.symbols("l", real=True) eq = sp.Eq(sp.sqrt(((l + 11) / 2) ** 2 - 36) - 13, sp.sqrt(((l - 11) / 2) ** 2 - 36)) print(sp.solveset(eq, l, domain=sp.S.Reals))LikeLiked by 1 person
Jim Randell 11:43 am on 14 September 2025 Permalink |
@ruud: I said it looks unlikely, because the puzzle text can be read to imply that the brothers do not follow the road because the horses would have to go for 13 km without water.
LikeLike
Ruud 11:59 am on 14 September 2025 Permalink |
I didn’t read it like that.
LikeLike
Ruud 3:41 pm on 14 September 2025 Permalink |
The advantage of sympy over enigma.find_zero is that sympy results in an exact answer, whereas find_zero is an approximation using a golden section search.
But of courae, sympy can’t solve arbitary expressions.
LikeLike
Jim Randell 4:14 pm on 14 September 2025 Permalink |
@Ruud: True. Although if we substitute the answer found by my programs using [[
find_zero()]] into the equations we see that they are indeed exact answers. And the code runs over 1000× faster than using SymPy.But I also wrote a program that gives an exact answer using the [[
Polynomial()]] class. And it still runs many times faster than using SymPy. (It generates a quadratic equation, and then solves it using the quadratic formula).LikeLike
Ruud 4:28 pm on 14 September 2025 Permalink |
Thanks for the clear explanation.
LikeLike
Alex T Sutherland 3:45 pm on 17 September 2025 Permalink |
Problem Solution:- Using Cosine Rule and Quadratic Equation. Triangle:- Obtuse. Sides 'a' , 'b' = 'a'+11, & 13. Method:- Solve for side 'a' using the Cosine Rule. ie b^2 = [a^2 + 13^2 - 2*a*13*cos(B)]; B =angle oppsite side 'b'. (a+11)^2 = [ " ];.........(1) -cos(B) is determined in terms of 'a' from the small right angled triangle. -cos(B) = sqrt(1- (6/a)^2); ;........(2) From (1) & (2) integer coefficients (m n p) can be determined for the qudratic m*(a*a) + n*a + p = 0; Solve the quadratic for 'a'. May use a roots function or the standard equation. Problem Answer:- 2*a + 11; Time:- The following were those obtained from a 15+ years old PC. (Running Non Python). Elapsed time is 0.007039 seconds. Jim Randell's initial solution. Elapsed time is 0.000216 seconds. Above method using a roots solver. Elapsed time is 0.000102 seconds. Above method using the standard equation. Code length:- 1 line; Maybe 2 in specifing the coefficients. SideLine:- The sum of the digits in the coefficients is 1 more than the problem answer.LikeLike