/* Unknown multiplication in Picat. Standard Prolog benchmark (GNU Prolog) """ Name : multipl.pl Title : unknown multiplication Original Source: Daniel Diaz - INRIA France Adapted by : Daniel Diaz for GNU Prolog Date : June 1995 Find the value of each digit verifying the following multiplication and such that each digit (0,1,...,9) appears excatly twice: X1 X2 X3 * X4 X5 X6 ----------- X7 X8 X9 + X10 X11 X12 + X13 X14 X15 = ------------------- X16 X17 X18 X19 X20 """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> LD=[X1,X2,X3,X4,X5,X6,X7,X8,X9,X10, X11,X12,X13,X14,X15,X16,X17,X18,X19,X20], LD :: 0..9, L = [Y,Z1,Z2,Z3], L :: 0..1000, % Exactly two occurrences global_cardinality(LD,$[I-2 : I in 0..9]), Y#=100*X1+10*X2+X3, Z1 #= 100*X7 +10*X8 +X9, Z2 #= 100*X10+10*X11+X12, Z3 #= 100*X13+10*X14+X15, X6*Y #= Z1, X5*Y #= Z2, X4*Y #= Z3, 100*X7 + 10*X8 + X9 + 1000*X10 + 100*X11 + 10*X12 + 10000*X13 + 1000*X14 + 100*X15 #= 10000*X16 + 1000*X17 + 100*X18+ 10*X19 +X20, Vars = LD ++ L, solve([split],Vars), println(LD), fail, nl. go => true.