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,533
  • 12
  • 98
  • 192

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
  • 19,674
  • 4
  • 52
  • 161