Send
Close Add comments:
(status displays here)
Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Prolog: Puzzles
1. Prolog: Puzzles
2. Constraint logic
Constraint logic can be used to pose and solve various types of puzzles.
3. Boy girl puzzle
Here is one puzzle. Can you solve it?
1. There are 3 boys and 3 girls.
2. One girl is dressed in red, one in green, one in blue.
3. One boy is dressed in red, one in green, one in blue.
4. The boy in red danced with the girl in green.
5. No boy danced with a girl who was dressed in the same color.
6. Which boy danced with the girl dressed in red?
adapted from Gardner (1978, p. 92-93).
As Gardner states,
Most people do not find it easy to follow the reasoning in the solution to this problem.
4. Another puzzle
Five of Carmi Parker's friends went on vacation at the same time last winter, and Carmi was delighted to watch each person's dog (no two of which are the same breed) while that friend was away. From the information provided, can you determine the first and last names (one first name is Kay, and one surname is Fankle) of the owner of each dog (one dog, ironically enough, is named Kitty), as well as the breed of each dog.
1. Carole (who is neither the one surnamed Peters nor the owner of the dog named Fido) owns the German shepherd.
2. The one surnamed Baxter owns the Dalmation (which isn't the dog named Alex). Alex isn't the golden retriever.
3. Alice (who is neither the one who owns the cocker spaniel nor the one who owns the Dalmation) is Sheba's owner.
4. Four of the owners are the one surnamed Johannson (who doesn't own the cocker spaniel), Heidi, the one who owns Fido, and the one who owns the greyhound.
5. Michelle is neither the one surnamed Peters (who is not Sheba's owner) nor the one who owns the cocker spaniel.
6. Alex is neither the cocker spaniel nor the dog owned by Carole. The dog named Fido isn't the cocker spaniel.
7. The one surnamed Lawton is neither the one who owns Rollie nor the one who owns the German shepherd.
5. Zebra puzzle
Here is the famous Zebra puzzle. For more info, see "
Zebra puzzle" on Wikipedia. The following version of the puzzle appeared in Life International in 1962:
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.
Now, who drinks water? Who owns the zebra?
There are many solutions to this puzzle using Prolog on the Internet.
6. End of page