# Enigmatic Code

Programming Enigma Puzzles

## Puzzle 28: Cross number

From New Scientist #1079, 24th November 1977 [link] Across:

1. Three of these digits are those of 6 across, not necessarily in the same order, and the other one is the sum of the digits of 6 across.
5. A multiple of the square root of 7 down.
6. A perfect cube.
8. A multiple of 23.
9. This is a prime number when reversed.
10. Each digit is greater than the one before.
12. The sum of the digits is 12.

Down:

1. The sum of the digits of this number is the same as the sum of the digits of 3 down.
2. The same when reversed.
3. See 1 down.
4. Each digit is greater than the one before.
7. A perfect square.
8. A multiple of 19.
11. A prime number.

[puzzle28]

### 2 responses to “Puzzle 28: Cross number”

1. Jim Randell 27 February 2019 at 7:58 am

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

The following run file executes in 198ms.

Run: [ @repl.it ]

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

#    A  B  C  D  #
#    E  F  G  H  I
#    J  K  #  L  M
#    N  P  Q  R  S
#    #  T  U  V  #

SubstitutedExpression

--distinct=""
--template=""

# 1a. "1. Three of these digits are those of 6 across, not necessarily
# in the same order, and the other one is the sum of the digits of 6
# across."
"ordered(A, B, C, D) == ordered(G, H, I, G + H + I)"

# 5a. "A [proper] multiple of the square root of 7 down."
"div(EF, is_square(IMS)) > 1"

# 6a. "A perfect cube."
"is_cube(GHI)"

# 8a. "A [proper] multiple of 23."
"div(JK, 23) > 1"

# 9a. "This is a prime number when reversed."
"is_prime(ML)"

# 10a. "Each digit is greater than the one before."
"N < P" "P < Q" "Q < R" "R < S"

# 12a. "The sum of the digits is 12."
"T + U + V = 12"

# 1d. "The sum of the digits of this number is the same as the sum of
# the digits of 3 down."
"A + E == C + G"

# 2d. "The same when reversed."
"B = T" "F = P"

# 3d. "See 1 down."

# 4d. "Each digit is greater than the one before."
"D < H" "H < L" "L < R" "R < V"

# 7d. "A perfect square."
"is_square(IMS)"

# 8d. "A [proper] multiple of 19."
"div(JN, 19) > 1"

# 11d. "A prime number."
"is_prime(QU)"
```

Solution: Here is the completed grid: 2. GeoffR 28 February 2019 at 8:37 am
```% A Solution in MiniZinc

%   A  B  C  D  #         5  2  8  1  #
%   E  F  G  H  I         4  6  1  2  5
%   J  K  #  L  M         9  2  #  3  2
%   N  P  Q  R  S         5  6  7  8  9
%   #  T  U  V  #         #  2  1  9  #

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 0..9:H; var 1..9:I; var 1..9:J;
var 1..9:K; var 1..9:L; var 1..9:M; var 1..9:N; var 1..9:P;
var 1..9:Q; var 1..9:R; var 1..9:S; var 1..9:T; var 1..9:U;
var 1..9:V; var 1..9:X; var 1..9:Y;

var 10..99: XY = 10*X + Y;  % sq rt of IMS

predicate is_prime(var int: x) =
x > 1 /\ forall(i in 2..1 + ceil(sqrt(int2float(ub(x))))) ((i < x) -> (x mod i > 0));

var 11..99: EF = 10*E + F;
var 100..999: GHI = 100*G + 10*H + I;
var 11..99: JK = 10*J + K;
var 11..99: LM = 10*L + M;

var 11..99: JN = 10*J + N;
var 100..999:IMS = 100*I + 10*M + S;
var 11..99: QU = 10*Q + U;

% Clue 1 Across (ABCD)
% Three of these digits are those of 6 across, not necessarily in the same order,
% and the other one is the sum of the digits of 6 across
var set of int: s1 = { A, B, C, D };  % Digits of 1 Across
var set of int: s2 = { G, H, I };     % Digits of 6 Across

constraint G in s1 /\ H in s1 /\ I in s1;
constraint A == G + H + I \/ B == G + H + I \/ C == G + H + I \/ D == G + H + I;

% Clue 5 Across (EF)- A multiple of the square root of 7 down
constraint  XY * XY == IMS /\ EF mod XY == 0;

% Clue 6 Across (GHI)-  A perfect cube
set of int: cb3 = {n*n*n | n in 5..9};
constraint GHI in cb3;

% Clue 8 Across (JK) - A multiple of 23
constraint JK mod 23 == 0;

% Clue 9 Across (LM)- This is a prime number when reversed
constraint is_prime(10*M + L);

% Clue 10 Across (NPQRS)- Each digit is greater than the one before
constraint P > N /\ Q > P /\ R > Q /\ S > R;

% Clue 12 Across (TUV) - The sum of the digits is 12
constraint T + U + V == 12;

% Clue 1 Down (AE)
% The sum of the digits of this number is the same as the sum of the digits of 3 down
constraint A + E == C + G;

% Clue 2 Down (BFKPT)- Number is a 5-digit palindrome
constraint B == K /\ B == T /\ F == P /\ F != T;

% Clue 3 Down (CG)
% See 1 Down

% Clue 4 Down (DHLRV)- Each digit is greater than the one before
constraint H > D /\ L > H /\ R > L /\ V > R;

% Clue 7 Down (IMS) - A perfect square
set of int: sq3 = {n*n | n in 10..31};
constraint IMS in sq3 /\ XY * XY == IMS;

% Clue 8 Down (JN) A multiple of 19
constraint JN mod 19 == 0;

% Clue 11 Down (QU) -  A prime number
constraint is_prime(QU);

solve satisfy;

% A = 5; B = 2; C = 8; D = 1;
% E = 4; F = 6;
% G = 1; H = 2; I = 5;
% J = 9; K = 2;
% L = 3; M = 2;
% N = 5; P = 6; Q = 7; R = 8; S = 9;
% T = 2; U = 1; V = 9; X = 2; Y = 3;
%----------
% ==========
% Finished in 252msec
```

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