### Random Post

### Recent Posts

- Puzzle 50: Football and addition
- Enigma 1066: Members of the clubs
- Enigma 443: The bells they are a-changing
- Tantalizer 455: Ballistico
- Tantalizer 456: Square deal
- Enigma 1067: Bye!
- Enigma 442b: Oh yes I did! Oh no you didn’t!
- Puzzle 51: A multiplication
- Enigma 1068: Triangular Fibonacci squares
- Enigma 442a: Hark the herald angels sing

### Recent Comments

### Archives

### Categories

- article (11)
- enigma (1,165)
- misc (2)
- project euler (2)
- puzzle (42)
- site news (45)
- tantalizer (45)
- teaser (3)

### Site Stats

- 180,250 hits

Advertisements

This Python program is a direct implementation of the problem statement, and finds the solution in 41ms. I’m sure I can make a prettier version though.

Solution:The two shaded numbers are 41 and 571.Here is the completed grid.

Here’s a slightly cleverer (and also slightly slower) Python program that gets the same solution. It runs in 69ms.

You can also use the generic cross figure solver given in my solution for

Enigma 1760to solve this problem. But it isn’t quick – it takes 3m26s under PyPy – because the condition that the columns sum to the same value is not checked until the the grid is filled out. But here’s the code if you want to see it.Numbering the grid as for a crossword, as shown in this diagram.

The digits of all columns add to the same sum, which must be less than 10 due to the middle digit of 6 across.

So 1 down must be 23 (29 would make the common sum more than 1 digit).

7 down must be 11, (if it were 13 or 31, the common digit sum would be 9, so the 3 digit numbers would not be prime)

So the common column digit sum is 7, which is the middle digit of 6 across.

3 across must be 31 (37 would be too large for 4 down)

Some code for the rest:

Each square contains a single digit, so we can use the alphametic solver (

SubstitutedExpression()) from theenigma.pylibrary to solve this puzzle, by expressing the constraints as Python expressions.Here is a run-file that executes in 120ms.

With analysis we can provide additional constraints. For example: no prime can start or end with a zero, so none of the letters (except

H) can be zero, but all the columns must sum toH, so it can’t be zero either, hence we could add the parameter--digits="1-9". Also none of the digits that end a prime (with more than 1 digit) can be 2, 4, 5, 6, 8, so we could also add the parameter--invalid="2|4|5|6|8,CDFJLMNPQ", although these provide only a modest reduction in overall execution time.