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

- 177,959 hits

Advertisements

Programming Enigma Puzzles

25 December 2015

Posted by on **From New Scientist #1473, 12th September 1985** [link]

An n-circuit is drawn on a triangular grid made up of equilateral triangles. It is a closed path of n different points and n different legs. Every leg runs along a grid-line and every point is a junction of grid-lines. Legs do not overlap, but they may cross.

A clear circuit is one that you cannot make a circuit with just some of the points. Thus the 5-circuit

Ais not clear. Points 1, 2 and 5 would make a 3-circuit: so would points 3, 4 and 5. ButBis clear.The fatness of a circuit is the area it encloses. Thus

Ahas fatness 5 (measured by the number of little triangles enclosed), andBhas fatness 7.Can you find a clear 9-circuit with a fatness of 9 (or less)?

**Happy Christmas** from **Enigmatic Code**!

[enigma325]

Advertisements

%d bloggers like this:

I thought this was an interesting puzzle to solve programatically.

Firstly we have to deal with the triangular grid (rather than the more normal rectilinear one). I used a similar approach to that in

Enigma 175, where I consider grid axes that are 60° apart.Then we have to write code that will generate “clear” circuits with the required number of legs. I generate circuits with increasing maximum leg lengths.

And finally we have to compute enclosed area of a (possibly) self-crossing circuit. My approach was to construct a box on the grid that encloses the shape, and then label all the triangles inside that box. We start by labelling a triangle on the outside of the shape with 0, then we label all adjacent triangles with 0 or 1 according to whether the shared edge of the adjacent triangles is part of the perimeter of the shape. If the shared edge is not included in the shape, then the value remains unchanged. But if the shared edge is included in the shape then value changes (from 0 to 1, or 1 to 0).

Here is my Python program. It finds the first solution to the puzzle in 7.5s, but you can leave it running to find more solutions.

Solution:Yes – it is possible to find a clear 9-circuit with a fatness of 9 (or less).The neatest looking solution, with a fatness of 7, is shown below:

The maximum leg length is 4.

This figure was the published solution.

Although there are other solutions, with a maximum leg length of 4, that have a fatness of 9:

It could be argued that, although these shapes are less pleasing to the eye, they are a better fit to the question posed in the puzzle.

There are also solutions with a maximum leg length of 5 that also have a fatness of 9:

(Of course the shapes given can be reflected and/or rotated to give similar solutions).

For other Enigmas that have fun on triangular grids see:

Enigma 82,Enigma 144,Enigma 175,Enigma 1774.