【发布时间】:2015-03-23 14:59:42
【问题描述】:
PYP
CQB
CBCW
-----
WXYPB
其中每个字母代表 0 到 9 之间的唯一数字,线下方的值代表其相关数字的总和。
【问题讨论】:
-
我已经添加了相关标签:你会在那里找到你想要的“发送更多钱”
-
@false 甜。谢谢x
标签: prolog clpfd cryptarithmetic-puzzle
PYP
CQB
CBCW
-----
WXYPB
其中每个字母代表 0 到 9 之间的唯一数字,线下方的值代表其相关数字的总和。
【问题讨论】:
标签: prolog clpfd cryptarithmetic-puzzle
查看非常相关问题Faster implementation of verbal arithmetic in Prolog。
基于my previous answer,让我们使用clpfd解决您的特定方程!
?- 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.
【讨论】: