:- initialization(run).
/* A + B = C */
abc
(A
,B
,C
) :- nonvar
(A
), nonvar
(B
), write('A+B '), !, C is A
+B
.abc
(A
,B
,C
) :- nonvar
(A
), nonvar
(C
), write('C-A '), !, B is C
-A
.abc
(A
,B
,C
) :- nonvar
(B
), nonvar
(C
), write('C-B '), !, A is C
-B
./* no idea how to solve */
abc
(A
,B
,C
) :- write('figvam '), fail
.
writes
([]) :- write('\n').writes
([X
|Xs
]) :- write(X
), writes
(Xs
).
test(A,B,C) :-
writes(['start...']),
abc(A,B,C),
writes(['A=',A, ' B=',B, ' C=',C]);
writes(['failed.']).
run :-
test(1,4,_),
test(1,_,5),
test(_,4,5),
test(1,4,5),
test(1,2,10),
test(_,_,10),
test(_,10,_),
test(10,_,_).
Oi0gaW5pdGlhbGl6YXRpb24ocnVuKS4KCi8qIEEgKyBCID0gQyAqLwphYmMoQSxCLEMpIDotIG5vbnZhcihBKSwgbm9udmFyKEIpLCB3cml0ZSgnQStCICcpLCAhLCBDIGlzIEErQi4KYWJjKEEsQixDKSA6LSBub252YXIoQSksIG5vbnZhcihDKSwgd3JpdGUoJ0MtQSAnKSwgISwgQiBpcyBDLUEuCmFiYyhBLEIsQykgOi0gbm9udmFyKEIpLCBub252YXIoQyksIHdyaXRlKCdDLUIgJyksICEsIEEgaXMgQy1CLgovKiBubyBpZGVhIGhvdyB0byBzb2x2ZSAqLwphYmMoQSxCLEMpIDotIHdyaXRlKCdmaWd2YW0gJyksIGZhaWwuCgp3cml0ZXMoW10pIDotIHdyaXRlKCdcbicpLgp3cml0ZXMoW1h8WHNdKSA6LSB3cml0ZShYKSwgd3JpdGVzKFhzKS4KCnRlc3QoQSxCLEMpIDotCgl3cml0ZXMoWydzdGFydC4uLiddKSwKCWFiYyhBLEIsQyksCgl3cml0ZXMoWydBPScsQSwgJyBCPScsQiwgJyBDPScsQ10pOwoJd3JpdGVzKFsnZmFpbGVkLiddKS4KCnJ1biA6LQoJdGVzdCgxLDQsXyksCgl0ZXN0KDEsXyw1KSwKCXRlc3QoXyw0LDUpLAoJdGVzdCgxLDQsNSksCgl0ZXN0KDEsMiwxMCksCgl0ZXN0KF8sXywxMCksCgl0ZXN0KF8sMTAsXyksCgl0ZXN0KDEwLF8sXyku