Sunday Times Teaser 2630 – River Crossing
by Des MacHale
Two walkers were returning to their tent, a short distance south east of them on the other side of a five metre wide river running east to west.
They both minimised their distance while in the water, one taking the shortest possible route with this constraint and the other simply going south and then east.
The shorter of these two routes was three quarters of the longer one.
What was its length?
4 Comments
Leave one →
It is easy to solve this manually since it involves a simple quadratic equation. It is also trivial to solve in Python, but to make things more interesting, here is a Python solution using a Golden Section search for a function minimum.
The version above finds the minimum of the squared difference between the the shortest and three quaters of the longest route. But we can instead simply look for the root (i.e. without the squaring) using a Brent method root solver.
In this example the time difference is minimal but in more complex examples the root finding method will generally be much faster.
Here is a manual solution.
Since the position of the river doesn’t matter, put the starting point its northern edge so that both routes immediately cross it. Let the southerly and easterly distances on the longest route be \(x\) metres.
So the distances on the longer and shorter routes are \(2x\) and \(5+\sqrt{x^2+(x-5)^2}\) respectively. Setting the shorter route equal to three quarters of the longer one now gives:
$$\begin{array} ((3x/2-5)^2=&x^2+(x-5)^2 \\ 9x^2/4-15x+25=&2x^2-10x+25 \\ x^2/4 – 5x=&0 \\ x(x-20)=&0 \end{array}$$
This gives x as 20 metres and the shorter of the two routes as 30 metres.
bm_solve() will not find the root for some complex functions.
Chandrupatla gives the correct x = 2.7541183874033877
Another root finding method (code from the internet)
And another…