我需要使用prolog来解决以下问题 这些是提供的事实。
1. The Greek ship leaves at six and carries coffee.
2. The Ship in the middle has a black chimney.
3. The English ship leaves at nine.
4. The French ship with blue chimney is to the left of a ship that carries coffee.
5. To the right of the ship carrying cocoa is a ship going to Marseille.
6. The Brazilian ship is heading for Manila.
7. Next to the ship carrying rice is a ship with a green chimney.
8. A ship going to Genoa leaves at five.
9. The Spanish ship leaves at seven and is to the right of the ship going to Marseille.
10. The ship with a red chimney goes to Hamburg.
11. Next to the ship leaving at seven is a ship with a white chimney.
12. The ship on the border carries corn.
13. The ship with a black chimney leaves at eight.
14. The ship carrying corn is anchored next to the ship carrying rice.
15. The ship to Hamburg leaves at six.
Which ship goes to Port Said? Which ship carries tea?
我在网上搜索,但是我无法找到prolog的解决方案。
那么如何用prolog解决这个问题?
谢谢。
答案 0 :(得分:2)
爱因斯坦的谜语Zebra puzzle,是一个逻辑谜题,可以通过编程方式解决。
它有几种变体,都是你发布的变种形式。
SPOILER ALERT :以下链接包含该难题的prolog解决方案
ic
(约束求解器)库的解决方案:https://gist.github.com/JuanitoFatas/2227711