Csc 4330/6330, Programming Language Concepts (Spring 2018)

Zebra Puzzle (Due: 29 April (Sunday))

Write a Prolog program (zebra.pl) to solve the "Zebra Puzzle".

The Zebra Puzzle is a logic puzzle said to be invented by Albert Einstein (but who knows), and Wikipedia says that only 2% of the world population is able to solve it, most of them being Prolog programmers like you :-).

The puzzle consists of five different-colored houses in a row, each lived in by a resident of a different nationality. Each resident owns a different pet, prefers a different drink, and smokes a different brand of cigarettes than the others.

You’re given 15 other facts:

  1. There are five houses.
  2. The Englishman lives in the red house.
  3. The Spaniard owns the dog.
  4. Coffee is drunk in the green house.
  5. The Ukrainian drinks tea.
  6. The green house is immediately to the right of the ivory house (to your right as you stand facing the row of five houses).
  7. The Old Gold smoker owns snails.
  8. Kools are smoked in the yellow house.
  9. Milk is drunk in the middle house.
  10. The Norwegian lives in the first house.
  11. The man who smokes Chesterfields lives in the house next to the man with the fox.
  12. Kools are smoked in a house next to the house where the horse is kept.
  13. The Lucky Strike smoker drinks orange juice.
  14. The Japanese smokes Parliaments.
  15. The Norwegian lives next to the blue house.
To solve the puzzle, tell me:
  1. Which man likes to drink water?
  2. Which man owns a zebra?