Enigmatic Code

Programming Enigma Puzzles

Enigma 1179: Making a splash

From New Scientist #2335, 23rd March 2002 [link]

My square courtyard garden, of less than 100m², occupies a whole number of square metres. I marked out my octagonal pool in the middle of the garden by running lines from each corner of the square to the mid-points of the two sides opposing that corner. The perimeter of the octagon is a whole number of metres.

What is the area of my courtyard garden?

What is the perimeter of my octagonal pool?

[enigma1179]

One response to “Enigma 1179: Making a splash”

1. Jim Randell 22 February 2016 at 7:53 am

If we consider one quadrant of the square divided into a grid of 6×6 squares, we see that the area of the octagon is 6/36 = 1/6 the area of the square. We also see that each side of the octagon is √5 times the side of one of the small squares in the grid.

If the large square has area A then the perimeter of the octagon is p = (2/3)(√5)(√A).

So: = 20A/9

It follows that A must be a multiple of 9. So there are only 11 candidates for A.

If A = 9n (n=1 to 11), then = 20n, so 20n must be a perfect square.

We can examine the possibilities by hand (I think it’s pretty obvious what n must be for 20n to be a square number), or this Python program runs in 34ms.

```from enigma import irange, is_square, printf

for n in irange(1, 11):
p = is_square(20 * n)
if p is not None:
A = 9 * n
printf("A={A} p={p}")
```

Solution: The area of the courtyard garden is 45m². The perimeter of the octagonal pool is 10m.