AM + PM = DAY CryptoArithmetic Puzzle Prolog

155 Views Asked by At

I need the output to be in the format below. I have the exact output except the last line, and I cannot figure out how to add the last line to the output. I would appreciate any help.

Output

    A = 2,
    M = 5,
    P = 9,
    D = 1,
    Y = 0,
    [2,5]+[9,5]=[1,2,0];

Code

    :- use_module(library(clpfd)).
    puzzle([A,M] + [P,M] = [D,A,Y]) :-
              Vars = [A,P,M,D,Y],
              Vars ins 0..9,
              all_different(Vars),
              A*10 + M + P*10 + M #= D*100 + A*10 + Y,
              A #\= 0,P #\= 0, D #\= 0,
              label([A,P,M,D,Y]).
0

There are 0 best solutions below