### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,183)
- misc (2)
- project euler (2)
- puzzle (46)
- site news (46)
- tantalizer (49)
- teaser (3)

### Site Stats

- 184,820 hits

Advertisements

Programming Enigma Puzzles

12 December 2012

Posted by on **From New Scientist #2895, 15th December 2012** [link]

Joe was in his school’s rugby team. While practising tackling, Joe remembers standing on the goal line 25 feet from his friend Ken, who was by the corner flag. When the master blew his whistle, Ken ran along the touchline and Joe had to try to tackle him. Ken runs at half a mile an hour faster than Joe, who could only manage 12 miles an hour. So Joe never caught up with Ken.

What was the nearest Joe came to Ken?

It is pleasing that **Enigma 1728** should be published on 12.12.12, as 1728 = 12³.

[enigma1728]

Advertisements

%d bloggers like this:

Assuming I understand they layout of rugby pitches correctly. This is a solution that uses the functions I recently added to the

enigma.pylibrary to find numerical approximations of functions. (It is implemented using a Golden Section Search minimiser). It runs in 45ms.Solution:Assuming Joe manages the minimum achievable distance, the closest he comes to Ken is 7 ft.Here’s a symbolic solution using SymPy.

By using the observation that the minimum distance occurs when J is travelling directly towards K, you can deduce the equation for the minimum distance as:

d = 25 / sin(θ) – 24 / tan(θ)

or more generally:

d = g(1/sin(θ) – r/tan(θ))

where r is the ratio

vand_{j}/ v_{k}gis the initial distance between Joe and Ken.By differentiation we find this is minimised in the case where cos(θ) = r.

And the solution follows.

hi, can we use any programming language here?

If you’d like to share a programmatic solution, then feel free. In whatever language you choose. (See the “Notes” page for some tips on posting source code in WordPress).

At the moment I tend to post my solutions in

Pythonas I find it lends itself to concise readable code (but then I initially started writing solutions in the somewhat more esotericPerl), and is freely available on many platforms (and even pre-installed on some), but it’s always interesting to see other languages too, and assuming it’s reasonably self-explanatory I should be able to understand the algorithm.This is the first python program whose belong to me, I have learned today a little

I think that’s a good start. Python is fairly easy to pick up (especially if you already know some other programming language), and has relatively few gotchas (although division using the / operator is one of them).

Converting the speeds to feet per second, this diagram derives the distance between Joe and Ken.

Then let Wolfram Alpha work out the minimum distance.

I have published an analytic solution to the problem on my blog.

However, I can’t work out why the form of the solution should be that the sine of the angle that Joe runs at is in proportion to the speeds of Joe and Ken.

The analytic solution now has a derivation of the general formula for the minimum distance, and the derivation of the sine of the angle being the proportion of the speeds

Very neat… I didn’t know you could get maths laid out so nicely in Blogger.

And I’ve just discovered you can use LaTeX markup directly in WordPress…

Did it work? It did for me.

(Although without the ability to preview/edit comments you might have to be careful when using this feature).

In roughly 4.675 seconds Ken runs 600/7 feet and Joe 24/25 as far.

I think I’m right in saying that if their starting positions (and roles) were reversed, the diagram would be the same triangle. In about 4.87 seconds Ken would run the extra 7, making 625/7 ft = 25/24 times as much as Joe’s 600/7.

Of course it all assumes that rugby players are more intelligent than the dog that always runs directly towards its master: this old dog can’t work out the equation of the pursuit curve.