# Sunday Times Teaser 2841 – Crenellation Aggregation

### by Stephen Hogg

#### Published 5th March 2017 (link)

The castle’s crenellated outer walls formed a pentagon, and on a family visit we decided to count the crenels. My son counted the number on each side and found that these totals on each side were five consecutive two figure numbers. My daughter and wife started together and then one of them walked clockwise around the walls and the other walked anticlockwise. They each counted the crenels they passed until they met. Their totals were two different prime numbers (with no prime number between the two). I consulted the tourist leaflet and found that the total number of crenels was in fact the product of three prime numbers.

How many crenels were there in total?

2. Here’s my solution.

It considers pairs of consecutive primes, and runs in 39ms.

We could use a bit of analysis to reduce the range of primes we consider, but it doesn’t seem worth it.

The enigma.py library is available at [ https://www.magwag.plus.com/jim/enigma.html ].

Here is a variation, based on the above approach of starting with adjacent primes: