/* pete1.pl * * CS 313 * * easy version of pete's puzzle solver */ solve(A, B, C, D) :- exp2(A, B, E1), exp2(C, D, E2), checkeq(E1, E2). exp2(A, B, A+B). exp2(A, B, A-B). exp2(A, B, A*B). exp2(A, B, A/B) :- B \= 0. checkeq(E1, E2) :- R1 is E1, R2 is E2, R1 = R2, write_ln(E1 = E2). /* fail. */ /* add 'fail' as last subgoal to print all solutions */