### 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

6 November 2013

Posted by on **From New Scientist #2942, 9th November 2013** [link]

A vertical piece of string is attached to a flat horizontal sheet of chicken wire, which forms a lattice of regular hexagons with 1-centimetre-long sides. The string is attached at one of the joints between three hexagons. Six ants marched down the string and along the wire, always moving further from their starting point on the wire. After a while, they had all marched the same distance along the wire (which was a whole number of centimetres less than 20 centimetres), but they were all at different straight-line distances from the starting point.

If I told you one of these straight-line distances, you would be able to calculate the straight-line distances the other five ants were from the starting point.

How far had the ants marched along the wire?

[enigma1774]

Advertisements

%d bloggers like this:

Here’s a Python 3 solution. It runs in 234ms. I’ll probably try another version as I have a natural dislike for

floats(although I’m sure 64-bit floats are up to the job for this puzzle).Solution:The ants had marched 11cm along the wire.We can remove the need to use

floatsby using a co-ordinate system where the axes are 60° apart (instead of the more usual 90°). The distance metric is given by the cosine rule, and I only track the squares of the distances to keep things in the integers (although I do calculate the actual distances in order to display the solution). This Python program runs in 40ms.Tidied up version

Another variation on the same theme, restricting the points reached to the quadrant where x and y coordinates are non-negative, and not considering steps that would always reduce the distance from the start point.