Created
January 3, 2015 15:44
-
-
Save shintakezou/6ae1730b309b90a5b74d to your computer and use it in GitHub Desktop.
This shows how to solve a simple problem on an italian quiz magazine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% gprolog: nth | |
% swi prolog: nth0 | |
vicino(List, A, B) :- | |
nth(IndexA, List, A), | |
nth(IndexB, List, B), | |
abs(IndexA - IndexB) =:= 1. | |
chi(Luca, Aldo, Berto) :- | |
vicino([4, 0, 2, 1, 3], Luca, Aldo), | |
vicino([1, 2, 3, 0, 4], Berto, Aldo), | |
\+ vicino([4, 0, 2, 1, 3], Luca, Berto), | |
Luca =\= 0, | |
Aldo =\= 0, | |
Berto =\= 0, | |
Luca =\= Aldo, | |
Luca =\= Berto, | |
Aldo =\= Berto. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment