【问题标题】:Write a Prolog program that solves the following arithmetic puzzle编写一个解决以下算术难题的 Prolog 程序
【发布时间】:2015-03-23 14:59:42
【问题描述】:
  PYP
  CQB
 CBCW
-----
WXYPB

其中每个字母代表 0 到 9 之间的唯一数字,线下方的值代表其相关数字的总和。

【问题讨论】:

  • 我已经添加了相关标签:你会在那里找到你想要的“发送更多钱”
  • @false 甜。谢谢x

标签: prolog clpfd cryptarithmetic-puzzle


【解决方案1】:

查看非常相关问题Faster implementation of verbal arithmetic in Prolog

基于my previous answer,让我们使用解决您的特定方程!

?- 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.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-03
    • 1970-01-01
    • 1970-01-01
    • 2013-08-19
    相关资源
    最近更新 更多