2
  PYP
  CQB
 CBCW
-----
WXYPB

where each letter represents a unique digit from 0-9 and the value below the line represents the sum of those about it.

false
  • 10,264
  • 13
  • 101
  • 209
  • 3
    I've added the relevant tags: You will find there exactly what you want as "Send more money" – false Mar 23 '15 at 15:01

1 Answers1

1

Check out the very related question Faster implementation of verbal arithmetic in Prolog.

Based on my previous answer, let's solve your specific equation using !

?- Eq = ([P,Y,P] + [C,Q,B] + [C,B,C,W] #= [W,X,Y,P,B]),
   crypt_arith_(Eq,Zs),
   labeling([],Zs).
Eq = ([9,3,9]+[8,7,5]+[8,5,8,1]#=[1,0,3,9,5]),
Zs = [9,3,8,7,5,1,0],
P  = 9,
Y  = 3,
C  = 8,
Q  = 7,
B  = 5,
W  = 1,
X  = 0 ;
false.
Community
  • 1
  • 1
repeat
  • 18,496
  • 4
  • 54
  • 166