/*
 http://sandbox.rulemaker.net/ngps/119

There are five houses.
The Englishman lives in the red house.
The Spaniard owns the dog.
Coffee is drunk in the green house.
The Ukrainian drinks tea.
The green house is immediately to the right of the ivory house.
The Old Gold smoker owns snails.
Kools are smoked in the yellow house.
Milk is drunk in the middle house.
The Norwegian lives in the first house.
The man who smokes Chesterfields lives in the house next to the man with the fox.
Kools are smoked in the house next to the house where the horse is kept.
The Lucky Strike smoker drinks orange juice.
The Japanese smokes Parliaments.
The Norwegian lives next to the blue house.

*/

next_to(X, Y, List) :- left_right(X, Y, List).
next_to(X, Y, List) :- left_right(Y, X, List).

left_right(L, R, [L, R | _]).
left_right(L, R, [_ | Rest]) :- left_right(L, R, Rest).

% house(Nationality, Pet, Smoke, Drink, Color)

zebra(Houses, Zebra_Owner, Water_Drinker) :-
  Houses = [house(norwegian, _, _, _, _), _, house(_, _, _, milk, _), _, _],
  member(house(englishman, _, _, _, red), Houses),
  member(house(spaniard, dog, _, _, _), Houses),
  member(house(_, _, _, coffee, green), Houses),
  member(house(ukrainian, _, _, tea, _), Houses),
  left_right(house(_, _, _, _, ivory), house(_, _, _, _, green), Houses),
  member(house(_, snails, old_gold, _, _), Houses),
  member(house(_, _, kool, _, yellow), Houses),
  next_to(house(_, _, chesterfield, _, _), house(_, fox, _, _, _), Houses),
  next_to(house(_, _, kool, _, _), house(_, horse, _, _, _), Houses),
  member(house(_, _, lucky_strike, orange_juice, _), Houses),
  member(house(japanese, _, parliment, _, _), Houses),
  next_to(house(norwegian, _, _, _, _), house(_, _, _, _, blue), Houses),
  member(house(Zebra_Owner, zebra, _, _, _), Houses),
  member(house(Water_Drinker, _, _, water, _), Houses).


	The Ukrainian drinks tea.
          member(house(ukrainian, _, _, tea, _), Houses),
	The Old Gold smoker owns snails.
          member(house(_, snails, old_gold, _, _), Houses),
	Kools are smoked in the yellow house.
          member(house(_, _, kool, _, yellow), Houses),
	The Lucky Strike smoker drinks orange juice.
          member(house(_, _, lucky_strike, orange_juice, _), Houses),
	The Japanese smokes Parliaments.
        member(house(japanese, _, parliment, _, _), Houses),
