Created
October 10, 2019 05:48
-
-
Save carrotflakes/04a86734950d3e72cbbb4169a441599e to your computer and use it in GitHub Desktop.
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
nextto(X, Y, List) :- iright(X, Y, List). | |
nextto(X, Y, List) :- iright(Y, X, List). | |
iright(Left, Right, [Left, Right | _]). | |
iright(Left, Right, [_ | Rest]) :- iright(Left, Right, Rest). | |
zebra(H, W, Z) :- | |
H = [house(norwegian, _, _, _, _), _, house(_, _, _, milk, _), _, _], | |
member(house(englishman, _, _, _, red), H), | |
member(house(spaniard, dog, _, _, _), H), | |
member(house(_, _, _, coffee, green), H), | |
member(house(ukrainian, _, _, tea, _), H), | |
iright(house(_, _, _, _, ivory), house(_, _, _, _, green), H), | |
member(house(_, snails, winston, _, _), H), | |
member(house(_, _, kools, _, yellow), H), | |
nextto(house(_, _, chesterfield, _, _), house(_, fox, _, _, _), H), | |
nextto(house(_, _, kools, _, _), house(_, horse, _, _, _), H), | |
member(house(_, _, luckystrike, oj, _), H), | |
member(house(japanese, _, parliaments, _, _), H), | |
nextto(house(norwegian, _, _, _, _), house(_, _, _, _, blue), H), | |
member(house(W, _, _, water, _), H), | |
member(house(Z, zebra, _, _, _), H). | |
zebra1(Houses, WaterDrinker, ZebraOwner) :- | |
zebra(Houses, WaterDrinker, ZebraOwner), !. | |
solve :- | |
repeat(I), | |
zebra1(Houses, WaterDrinker, ZebraOwner), | |
I=:=1000. | |
benchmark :- | |
S is cputime, | |
solve, | |
T is cputime-S, | |
write(T). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment