# Enigmatic Code

Programming Enigma Puzzles

## Enigma 510: Out of court

From New Scientist #1662, 29th April 1989 [link]

Professor Puzzleothers has privately decided to allow his ex-wife a resettlement of precisely one third his current annual salary, but only if she can work out exactly how much she is to get.

He instructs his solicitor to tell her lawyers that he will agree to alimony calculated according to the following formula.

She has to find two numbers A and B which between them contain each of the digits from 1 to 9 exactly once and contain no 0 digit, such that B = 2A, A is divisible by 3, and the quotient when A is divided by 3 is a number which contains all the digits from 1 to 4. Then £A will be the annual settlement.

What does Puzzleothers currently earn?

[enigma510]

### 2 responses to “Enigma 510: Out of court”

1. Jim Randell 29 July 2019 at 8:59 am

The two numbers a and b, contain all the digits from 1-9 exactly once and are such that b = 2a.

So a must consist of 4 digits and b must consist of 5 digits

So we can consider this as an alphametic problem where a = ABCD and b = EFGHI.

We can then use the [[ SubstitutedExpression() ]] solver from the enigma.py library to solve the puzzle.

The following run file executes in 147ms.

Run: [ @repl.it ]

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

SubstitutedExpression

--digits="1-9"

# 2 * a = b
"2 * ABCD = EFGHI"

# a is divisible by 3
"ABCD % 3 = 0"

# a/3 contains the digits from 1 to 4
"set([1, 2, 3, 4]).issubset(nsplit(div(ABCD, 3)))"
```

Solution: The professor’s salary is £21,879.

So we have:

a = 7293, b = 14586
a ÷ 3 = 2431

2. GeoffR 29 July 2019 at 9:37 am
```% A Solution in MiniZinc
include "globals.mzn";

var 1..9: a; var 1..9: b; var 1..9: c; var 1..9: d;  var 1..9: e;
var 1..9: f; var 1..9: g; var 1..9: h; var 1..9: i;

% four digits in the quotient
var 1..9: w; var 1..9: x; var 1..9: y; var 1..9: z;
var 1000..9999: Q;    % 4 digit quotient of A/3

constraint all_different ( [a, b, c, d, e, f, g, h, i] );

% As B = 2A, assume B has 5 digits and A has 4 digits
var 10000..99999: B = 10000*a + 1000*b + 100*c + 10*d + e;
var 1000..9999: A = 1000*f + 100*g + 10*h + i;

constraint B == 2 * A;

constraint A mod 3 == 0 /\ Q == A div 3;

% Find all digits in the quotient
constraint w == Q div 1000 /\ x == Q div 100 mod 10
/\ y == Q div 10 mod 10 /\ z == Q mod 10;

% use sets to show quotient Q contains all digits 1-4
constraint {w, x, y, z} = {1, 2, 3, 4};

solve satisfy;

output ["A = " ++ show(A) ++ ", B = " ++ show(B) ++
", A / 3 = " ++ show(A div 3) ++
"\nPuzzleothers currently earns £" ++ show(3 * A) ];

% A = 7293, B = 14586, A / 3 = 2431
% Puzzleothers currently earns £21879
% ----------
% ==========
% Finished in 224msec

```

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