"The challenge is to write a Prolog program to solve the following logic puzzle.
(a) The Englishman lives in the red house.They provide the solution to a simpler problem.
(b) The Spaniard owns the dog.
(c) Coffee is drunk in the green house.
(d) The Ukrainian drinks tea.
(e) The green house is immediately to the right (your right) of the ivory house.
(f) The Winston smoker owns snails.
(g) Kools are smoked in the yellow house.
(h) Milk is drunk in the middle house.
(i) The Norwegian lives in the first house on the left.
(j) The man who smokes Chesterfields lives in the house next to the man with the fox.
(k) Kools are smoked in the house next to the house where the horse is kept.
(1) The Lucky Strike smoker drinks orange juice.
(m) The Japanese smokes Parliaments.
(n) The Norwegian lives next to the blue house.
Who owns the Zebra? Who drinks water?"
Clare had a go and figured out that the water-drinker might be Norwegian, then things bogged down a little. My own programming efforts, meanwhile, were mired in bugs.
It is often the little things in life which absurdly please. Imagine my delight (spoilers follow) when my Prolog program produced the following output:
Logic Puzzle v. 0082For my next trick it's implementing one of those block-stacking planning programs, to be followed by Eliza. And after that, let's put them all together and have a go at a more interesting conversationalist.
Persons = [person(yellow,norwegian,fox,water,kools,1),
S = [['The zebra is owned by the ', japanese], ['the ', norwegian, ' drinks water']].