I need to test this code for crypt arithmetic for two + two = four but it is giving me false which is wrong. I need to know why is this happening. It works for donald+robert= gerald or it+is=me. I got the idea of how recursion works but since i cannot debug it I have no idea what is wrong.
sum(N1,N2,N) :-
sum1(N1,N2,N,0,0,[0,1,2,3,4,5,6,7,8,9], _).
sum1([], [], [], C,C,D,D).
sum1([D1|N1], [D2|N2], [D|N], CR, C, Digs1, Digs) :-
sum1(N1,N2,N, CR, CLN, Digs1, Digs2),
digsum(D1,D2, CLN, D, C, Digs2, Digs).
digsum(D1,D2, C1, D, C, Digs1, Digs) :-
del_var(D1, Digs1, Digs2),
del_var(D2, Digs2, Digs3),
del_var(D, Digs3, Digs),
S is D1+D2+C1,
D is S mod 10,
C is S // 10.
del_var(A,L,L) :-
nonvar(A), !.
del_var(A, [A|L], L).
del_var(A, [B|L], [B|L1]) :-
del_var(A,L,L1).