Skip to content

Instantly share code, notes, and snippets.

@shintakezou
Created January 3, 2015 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shintakezou/6ae1730b309b90a5b74d to your computer and use it in GitHub Desktop.
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.
% 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