Project Euler Problem 607

Frodo and Sam need to travel 100 leagues due East from point A to point B.

Project Euler Problem 607

Solution

Answer: 13.1265108586

Let the marsh boundaries be parallel lines running South-West to North-East.

The optimal path obeys the continuous analogue of Snell’s law:

$$\frac{\sin\theta_i}{v_i}=k$$

where:

  • $v_i$ is the speed in region $i$,
  • $\theta_i$ is the angle to the normal of the marsh boundaries,
  • $k$ is a constant.

The seven regions have speeds

$$(10,9,8,7,6,5,10)$$

and perpendicular widths

$$\left(\frac{100}{2\sqrt2}-25,\ 10,10,10,10,10,\ \frac{100}{2\sqrt2}-25\right).$$

Numerically solving

$$\sum_i d_i \tan\theta_i=\frac{100}{\sqrt2}, \qquad \sin\theta_i = k v_i$$

gives

$$k \approx 0.0841375064631515.$$

The total travel time is then

$$T=\sum_i \frac{d_i}{v_i\cos\theta_i}$$

which evaluates to

$$T \approx 13.1265108586.$$

Rounded to 10 decimal places:

Answer: 13.1265108586