# Solution: Send More Money

All puzzles are solved in the same manner. As an example, only the first solution is shown:

### The code for one of the standard puzzles...

```declare
proc {Send Root}
S E N D M O R Y
in
Root = solution(s:S e:E n:N d:D m:M o:O r:R y:Y)
Root ::: 0#9
{FD.distinct Root}
S \=: 0
M \=: 0
1000*S + 100*E + 10*N + D
+           1000*M + 100*O + 10*R + E
=: 10000*M + 1000*O + 100*N + 10*E + Y
{FD.distribute ff Root}
end

{ExploreOne Send}```

### ...and the search tree:

After clicking on the solution node, the Browser shows

```1#solution(d: 7 e: 8 m: 0 n: 1 o: 3 r: 6 s: 2 y: 5)
```

```declare
proc {Send Root}
W E I N W E I B L I E B E
in
Root = solution(w:W e:E i:I n:N b:B l:L)
Root ::: 0#9
{FD.distinct Root}
W \=: 0
L \=: 0
1000*W + 100*E + 10*I + N
+           1000*W + 100*E + 10*I + B
=: 10000*L + 1000*I + 100*E + 10*B + E
{FD.distribute ff Root}
end

{ExploreOne Send}```

### ...for the 2-dimensional cryptarithmetic problem,

you could write
```declare

% ABC + AA = DEF
%  :     +    :
%  GF :  C =   A
%  =     =    =
%  FH + DF = IID

% replace division by multiplication

proc {Crypt2D Root}
!Root=sol(A B C D E F G H I)
in
{FD.distinct !Root}
!Root ::: 0#9
%Rows, top to bottom
100*A + 10*B + C  +  10*A + A  =: 100*D + 10*E + F
A * C =: 10*G + F
10*F + H + 10*D + F =: 100*I + 10*I + D

%Columns, left to right
(10*F + H) * (10*G + F) =:  100*A + 10*B + C
10*A + A + C =: 10*D + F
(100*I + 10*I + D) * A =: 100*D + 10*E + F

{FD.distribute split Root}
end

{ExploreOne Crypt2D}
```
and get the solution
` A=8, B=6, C=4, D=9, E=5, F=2, G=3, H=7, I=1 `

Markus Löckelt