### Random Post

### Recent Posts

### Recent Comments

Jim Randell on Puzzle #52: Bus change | |

Jim Randell on Enigma 967: Prime cubes | |

GeoffR on Enigma 1707: Making progr… | |

Jim Randell on Enigma 1707: Making progr… | |

Jim Randell on Tantalizer 409: Fe, Fi, Fo,… |

### Archives

### Categories

- article (11)
- enigma (1,364)
- misc (4)
- project euler (2)
- puzzle (90)
- puzzle# (47)
- site news (58)
- tantalizer (92)
- teaser (7)

### Site Stats

- 231,899 hits

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 to`H`

, 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.