Beispiel #1
0
# The man who smokes Blue Master drinks Beer.
# The German smokes Prince.
# The Norwegian lives next to the Blue house.
# The man who smokes Blends has a neighbour who drinks Water.

pz = Puzzle()
pz.add_values("Home", [1, 2, 3, 4, 5])
pz.add_values("Color", ["Blue", "Green", "Red", "White", "Yellow"])
pz.add_values("Nationality", ["Brit", "Dane", "German", "Norwegian", "Swede"])
pz.add_values("Drink", ["Beer", "Coffee", "Milk", "Tea", "Water"])
pz.add_values("Cigarette",
              ["Blends", "Blue Master", "Dunhill", "Pall Mall", "Prince"])
pz.add_values("Pet", ["Birds", "Cats", "Dogs", "Horses", "Fish"])

# The Brit lives in the Red house.
pz.add_condition(Relationship.EQ, {"Nationality": "Brit"}, {"Color": "Red"})
# The Swede keeps Dogs as pets.
pz.add_condition(Relationship.EQ, {"Nationality": "Swede"}, {"Pet": "Dogs"})
# The Dane drinks Tea.
pz.add_condition(Relationship.EQ, {"Nationality": "Dane"}, {"Drink": "Tea"})
# The owner of the Green house drinks Coffee.
pz.add_condition(Relationship.EQ, {"Color": "Green"}, {"Drink": "Coffee"})
# The person who smokes Pall Mall rears Birds.
pz.add_condition(Relationship.EQ, {"Cigarette": "Pall Mall"}, {"Pet": "Birds"})
# The owner of the Yellow house smokes Dunhill.
pz.add_condition(Relationship.EQ, {"Color": "Yellow"},
                 {"Cigarette": "Dunhill"})
# The man living in the centre house drinks Milk.
pz.add_condition(Relationship.EQ, {"Home": 3}, {"Drink": "Milk"})
# The Norwegian lives in the first house.
pz.add_condition(Relationship.EQ, {"Nationality": "Norwegian"}, {"Home": 1})