# Enigmatic Code

Programming Enigma Puzzles

## Enigma 408: Royal numbers

From New Scientist #1558, 30th April 1987 [link]

In the following subtraction sum, each letter stands for a different digit. Replace the letters with digits.

[enigma408]

### 2 responses to “Enigma 408: Royal numbers”

1. Jim Randell 4 August 2017 at 9:51 am

We can re-write the subtraction sum as an addition sum and use the SubstitutedSum() solver from the enigma.py library to solve this puzzle.

The following run file executes in 130 ms.

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

SubstitutedSum

"CHARLES + CHEERED = ENGLAND"
```

Solution: The sum is: 3679462 – 1833532 = 1845930.

2. geoffrounce 4 August 2017 at 3:13 pm
```% A Solution in MiniZinc
include "globals.mzn";

var 1..9:C;   var 0..9:H;   var 0..9:A;   var 0..9:R;
var 0..9:L;   var 1..9:E;   var 0..9:S;   var 0..9:N;
var 0..9:G;   var 0..9:D;

constraint all_different([C, H, A, R, L, E, S, N, G, D]);

var 1234567..9876543 : CHARLES = C*1000000 + H*100000
+ A*10000 + R*1000 + L*100 + 10*E + S;

var 1234567..9876543 : CHEERED = C*1000000 + H*100000
+ E*10000 + E*1000 + R*100 + 10*E + D;

var 1234567..9876543 : ENGLAND = E*1000000 + N*100000
+ G*10000 + L*1000 + A*100 + 10*N + D;

constraint ENGLAND - CHEERED = CHARLES;

solve satisfy;

output ["Sum is " ++ show(ENGLAND) ++ " - " ++ show(CHEERED) ++ " = " ++ show(CHARLES) ];
% Sum is 3679462 - 1833532 = 1845930
% Finished in 62msec

```