### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,158)
- misc (2)
- project euler (2)
- puzzle (40)
- site news (44)
- tantalizer (42)
- teaser (3)

### Site Stats

- 178,002 hits

Advertisements

Programming Enigma Puzzles

12 August 2014

Posted by on **From New Scientist #2460, 14th August 2004**

As the crow flies, Joe lives 5 miles from each of his friends Ken and Les, who live 8 miles apart. Every Sunday lunchtime they meet at a convenient pub. It is convenient because the roads to it are straight and flat. They also chose this pub because its location meant they could all leave home at the same time and, after the shortest possible time, all arrive at the same time. Joe can only manage a steady 11 mph and Les a steady 14 mph on their bicycles. Ken, on his motor bike, is limited to 30 mph by the speed limit.

How long do they each take to reach the pub?

**Note:** I am waiting for a phone line to be connected at my new house, so I only have sporadic access to the internet at the moment.

[enigma1302]

Advertisements

%d bloggers like this:

This is an analytical solution, but I used SymPy to handle the equations. This Python program runs in 318ms.

Solution:Each friend takes 12 minutes to reach the pub.There is a second solution of 14 minutes, 56.4 seconds, but we are looking for the shortest possible time.

The solution works by considering the curves of points that are the required ratios of distances between J, K and L, as seen in the three curves on the graph.

All three curves intersect at two points, and these are the points of equal travel time between J, K and L.

Originally I solved this using Heron’s Formula for the area of a triangle, which gives the solution, but only because the location of the Pub does not lie outside the triangle JKL. If, for example, K was willing to risk travelling at 31mph, it wouldn’t find a solution. But it is quite simple to code up. Here it is:

And here’s a numerical solution, using the

find_min()GSS solver from theenigma.pylibrary. It runs in 37ms.