**From New Scientist #1343, 3rd February 1983** [link]

Once more, I’m afraid, there has been a mistake in Uncle Bungle’s latest addition puzzle. In this puzzle digits have been replaced by letters and the same letter should stand for the same digit wherever it appears, and of course different letters should stand for different digits. But all is not as it should be and *one* of the letters is wrong. The addition sum looks like this:

Write out the correct addition sum.

[enigma197]

### Like this:

Like Loading...

*Related*

This Python program uses the

SubstitutedSum()solver from theenigma.pylibrary. It runs in 923ms.Solution:The correct sum is either: 24994626 + 21098416 = 46093042, or: 24094626 + 21998416 = 46093042.One of the H’s in the two summands should be replaced with an R giving rise to the two answers (both give the same total in the sum), but we can’t determine which one of these is the “correct” sum.

I notice that the pattern 46093042 corresponds to the word SLAPDASH — more appropriate in the context of the puzzle than the meaningless jumble of letters used by the setter.

Here’s a solution that uses MiniZinc. I’ve used the

minizinc.pywrapper to make it simpler to generate the model. This Python 3.6 program executes in 397ms (using themzn-g12fdsolver – I found quite a wide variation in the run times (and accuracy) of the various solvers, but this one was the quickest, and gave the correct result).I used your idea of a substituted sum in your wrapper to see what it would look like in standard MiniZinc code. The fastest run-time I got was 309 msec – this varied a lot depending which solver I used.