# Solution: Twin Letters

### The code...

```declare
% A B C  *  D E F
% _______________
%           G H I
%         J K L
%       M N O
% _______________
%       P Q R S T

proc {Twice Root}
A B C D E F G H I J K L M N O P Q R S T
C1 C2 C3
in
Root = solution(a:A b:B c:C d:D e:E f:F g:G h:H i:I j:J
k:K l:L m:M n:N o:O p:P q:Q r:R s:S t:T)
Root ::: 0#9
C1 :: 0#1
C2 :: 0#2
C3 :: 0#1
%CarriesLow ::: 0#9
%CarriesHigh ::: 0#1

{For 0 9 1
proc {\$ I} {FD.exactly 2 Root I} end
}
100*G + 10*H + I +
1000*J + 100*K + 10*L +
10000*M + 1000*N + 100*O =:
10000*P + 1000*Q + 100*R + 10*S + T

(100*D + 10*E + F)*C =: 100*G + 10*H + I
(100*D + 10*E + F)*B =: 100*J + 10*K + L
(100*D + 10*E + F)*A =: 100*M + 10*N + O

(100*A + 10*B + C) * (100*D + 10*E + F) =:
10000*P + 1000*Q + 100*R + 10*S + T
% Carry restrictions
T         =: I
S + 10*C1 =: H + L
R + 10*C2 =: G + K + O + C1
Q + 10*C3 =: J + N + C2
P         =: M + C3

{FD.distribute generic(order:size) Root}
end

{ExploreOne Twice}
```

### ...and the search tree

The only solution then is

```Q=R=0, D=H=1, A=B=2, J=M=3, C=P=4,
K=N=5, I=T=6, E=G=7, L=O=8, F=S=9

224 * 179
_________
716
358
358
_________
40096
```

Markus Löckelt