### Random Post

### Recent Posts

- Enigma 1105: Road ants
- Enigma 406: The ritual
- Puzzle 69: Division: letters for digits
- Enigma 1106: Not a square unused
- Enigma 405: Uncle bungles the answer
- Enigma 401: Uncle bungles the answer
- Puzzle 70: Football five teams: new method
- Enigma 1107: Factory work
- Enigma 404: Regular timepiece
- Tantalizer 477: Precognition

### Recent Comments

Jim Randell on Enigma 1105: Road ants | |

geoffrounce on Enigma 35: Digits all wro… | |

hakank on Puzzle 70: Football five teams… | |

saracogluahmet on Enigma 1740: Sudoprime | |

Jim Randell on Enigma 406: The ritual |

### Archives

### Categories

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

### Site Stats

- 159,398 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 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="24568,CDFJLMNPQ", although these provide only a modest reduction in overall execution time.