### Random Post

### Recent Posts

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,176)
- misc (2)
- project euler (2)
- puzzle (44)
- site news (46)
- tantalizer (48)
- teaser (3)

### Site Stats

- 183,172 hits

Advertisements

Programming Enigma Puzzles

6 March 2013

Posted by on **From New Scientist #2907, 9th March 2013** [link]

In our local park the “Dodecagarden” is fenced in by 12 straight fences: the shortest is 1 metre long and the longest is less than 100 metres long.

The 12 corners of the garden all lie on a circle whose radius is a whole number of metres, and the 12 angles made at the corners by the fences are all equal.

Some of the fences have been reclaimed from an earlier use. Three shortest fences once enclosed a triangular garden and three longest fences once enclosed another triangular garden. The area of the larger triangle was a whole number times the area of the smaller one.

How many times?

**Enigma 1528** is also about cyclic polygons.

[enigma1739]

Advertisements

%d bloggers like this:

I’ll add a diagram later to explain the details. This Python program runs in 35ms.

Solution:The area of the larger triangle was 147 times the area of the smaller triangle.Here’s my derivation of the equations used in the above program:

A cyclic 12-gon with the same angles at the corners is either regular (all edges are the same length) or the edges alternate between two different lengths, which is the situation here. We are told there is a “longest” length and a “shortest” length (which is 1).

So let the longer sides have length

x, then the solution is the ratio of the areas of two equilateral triangles, one with sides of lengthxand one with sides of length 1. Hence the required ratioRisx²/1², which is justx².So consider one quadrant of the 12-gon (shown in blue):

The triangle shown in red has a hypotenuse of

r(the radius of the circle), a height of ½ (half the length of the shortest side), and a width ofx+ √3/2.So:

And if

ris an integer, then so isr², so it follows thatxis some multiple of √3.So let:

x=n√3Then:

The program considers increasing

n, untilx² (= 3n²) exceeds 10000 (and soxexceeds 100), looking for values ofnwhere 3n² + 3n+ 1 is a perfect square.Once this is found the required solution is the ratio of the areas of the equilateral triangles, which is

x².A more direct way to derive the relationship between

randxis to consider two adjacent sides of the 12-gon. (And it’s a much simpler diagram to draw).The angle

AOCis 60° and the sidesOA,OCare lengthr, henceAC=r.We then apply the cosine rule to the triangle

ABCto get:The rest of the solution follows as above.

If you solve the first quadratic above for x you can see that it does not follow that x is a multiple of root three

If

r² = x² + x√3 + 1, andr²andx²(and 1) are integers, thenx√3is also an integer, so letx√3 = m(for some integerm). Then:x = m/√3, so:x² = m²/3.But

x²is an integer, so 3 dividesm, so letm = 3n(for some integern). Hence:x = m/√3 = 3n/√3 = n√3.QED.

Please ignore my previous hasty comment.

In fact your method leads quickly to the underlying Pell equation (which I reached by a messier route) which can be solved easily.

Here is a solution using Pell’s equation:

I read up on Pell’s equation, and then realised that I wrote a solver for them (based on continued fraction convergents for square roots) for Project Euler Problem 66. My take on this approach is…

Starting from the equation

r² = 3n² + 3n + 1(derived above) and substitutinga = 2r,b = 2n + 1gives the Pell’s equation:a² – 3b² = 1. So any solution of the Pell’s equation with an even value foraand an odd value forbalso gives a solution for the original equation.We only need to consider the first four solutions generated by the solver (due to the upper limit on fence size), and only two of those are even/odd combinations required to solve the original equation.

For comparison my original code checks 57 candidates for

n, and if the upper limit for fence length was a much larger number than 100 it would be far more efficient to use the Pell’s equation solver than considering consecutive values ofn.There are 12 triangles whose top corners are located in the circle of r m radius and carry fences of 1 m and x m alternately where r is an integer number.

If A represents the equal angle of the dodecagarden we can deduce that

A=(12(180)-360)/12=150

Then the rotating fences create Isosceles triangles with angles of B and (150-B) which are CosB=0.5/r and Cos(150-B)=x/(2r)

The smallest 3 fences make up a triangle with an area of S(1)=SQRT(3)/4 and the largest 3 fences make up a triangle with an area of S(x)=(x^2)(SQRT(3))/4 , giving us S(x)/S(1)=x^2 which can take us to the solution.

#For python 2.7

I think you need to look at A up to 173 (=int(100√3)) to check all fences less than 100m. (Although as A² needs to be divisible by 3 you could do this in steps of 3).

Sure you are right