22.18 Jealousy: Answer

Answer for "Jealousy"

The suggested way of answering this is a follows:

jealous(X,Y):-
        involved_with(X,Z),
        involved_with(Y,Z).

It could also be:

jealous(X,Y):-
        involved_with(Z,X),
        involved_with(Z,Y).

since it does not matter whether we write involved_with(Z,X) or involved_with(X,Z). Alternative answers could even be:

jealous(X,Y):-
        involved_with(X,Z),
        involved_with(Z,Y).

or

jealous(X,Y):-
        involved_with(Z,X),
        involved_with(Y,Z).

The important thing is that both X and Y are involved with the third player, Z.


Prev: Poverty
Up: 22 A Murder Mystery
Next: Being involved with