# Enigmatic Code

Programming Enigma Puzzles

## Enigma 444: Rows and rows

From New Scientist #1595, 14th January 1988 [link]

Below is an addition sum with letters substituted for digits. The same letter stands for the same digit wherever it appears, and different letters stand for different digits.

Write the sum out with numbers substituted for letters.

[enigma444]

### 2 responses to “Enigma 444: Rows and rows”

1. Jim Randell 20 April 2018 at 9:07 am

We can feed this problem directly to the [[ `SubstitutedSum()` ]] solver from the enigma.py library.

This run file executes in 114ms.

Run: [ @repl.it ]

```#!/usr/bin/env python -m enigma -r

SubstitutedSum "SHSFFP + SBTFFP + SFHFFP + SHSFFP = JJAHVSP"
```

Solution: The sum is: 292880 + 273880 + 289880 + 292880 = 1149520.

2. geoffrounce 20 April 2018 at 10:09 am
```% A Solution in MiniZinc
include "globals.mzn";

var 0..9: S; var 0..9: H; var 0..9: F; var 0..9: P;
var 0..9: B; var 0..9: T; var 0..9: J; var 0..9: A;
var 0..9: V;

constraint all_different ([S, H, F, P, B, T, J ,A, V]) /\ S > 0 /\ J > 0;

var 100000..999999: SHSFFP = 100000*S + 10000*H + 1000*S + 110*F + P;
var 100000..999999: SBTFFP = 100000*S + 10000*B + 1000*T + 110*F + P;
var 100000..999999: SFHFFP = 100000*S + 10000*F + 1000*H + 110*F + P;

var 1000000..9999999: JJAHVSP = 1000000*J + 100000*J + 10000*A
+ 1000*H + 100*V + 10*S + P;

constraint 2 * SHSFFP + SBTFFP + SFHFFP == JJAHVSP;

solve satisfy;

output ["Sum is " ++ show(SHSFFP) ++ " + " ++ show(SBTFFP) ++ " + "
++ show(SFHFFP) ++ " + " ++ show(SHSFFP) ++ " = " ++ show(JJAHVSP) ];

% Sum is 292880 + 273880 + 289880 + 292880 = 1149520

```

This site uses Akismet to reduce spam. Learn how your comment data is processed.