{ Einstein's Challenge, also known as the Five Houses problem. Urban legend has it that this puzzle was written by Einstein and that he claimed only 2% of the world's population could solve it. THE PUZZLE There are five houses in five different colours. In each house lives a person of a different nationality. These five owners drink a certain beverage, smoke a certain brand of cigarette and keep a certain pet. No owners have the same pet, smoke the same brand of smoke or drink the same drink. HINTS {1} The Brit lives in the red house. {2} The Swede keeps dogs as pets. {3} The Dane drinks tea. {4} The green house is on the left of the white house. {5} The green house owner drinks coffee. {6} The person who smokes Pall Mall rears birds. {7} The owner of the yellow house smokes Dunhill. {8} The man living in the house right in the center drinks milk. {9} The Norwegian lives in the first house. {10} The man who smokes Blend lives next to the one who keeps cats. {11} The man who keeps horses lives next to the man who smokes Dunhill. {12} The owner who smokes Blue Master drinks beer. {13} The German smokes Prince. {14} The Norwegian lives next to the blue house. {15} The man who smokes Blend has a neighbour who drinks water. The question is: WHO OWNS FISH? Solution can be obtained by running the query: all Einstein(house, pets, smokes,drinks,order) House 1 2 3 4 5 Nationality Norwegian Dane Brit German Swede Color Yellow Blue Red Green White Pet Cats Horses Birds Fish Dog Beverage Water Tea Milk Coffee Beer Cigarettes Dunhill Blend Pall_Mall Prince Blue_Master } Nationality = Brit | Swede | Dane | Norwegian | German Color = Red | Green | Yellow | Blue | White Cigarettes = Pall_Mall | Dunhill | Blue_Master | Blend | Prince Pet = Dogs | Birds | Cats | Fish | Horses Beverage = Tea | Coffee | Milk | Beer | Water HouseOrder = First | Second | Third | Fourth | Fifth Pets = Nationality->>Pet Drinks = Nationality->>Beverage House = Nationality->>Color Smokes = Nationality->>Cigarettes Order = HouseOrder->>Nationality pred Einstein(house::House, pets::Pets, smokes::Smokes,drinks::Drinks,order::Order) iff {1} house(Brit) = Red & {2} pets(Swede) = Dogs & {3} drinks(Dane) = Tea & {4} house(x4) = Green & house(x4a) = White & LeftOf(x4,x4a,order) & {5} house(x5) = Green & drinks(x5) = Coffee & {6} smokes(x6) = Pall_Mall & pets(x6) = Birds & {7} house(x7) = Yellow & smokes(x7) = Dunhill & {8} drinks(order(Third)) = Milk & {9} order(First) = Norwegian & {10} smokes(x10) = Blend & pets(x10a) = Cats & Neighbour(x10,x10a,order) & {11} smokes(x11) = Dunhill & pets(x11a) = Horses & Neighbour(x11,x11a,order) & {12} smokes(x12) = Blue_Master & drinks(x12) = Beer & {13} smokes(German) = Prince & {14} house(Norwegian) <> Blue & house(order(Second)) = Blue & {15} smokes(x15) = Blend & drinks(x15a) = Water & Neighbour(x15,x15a,order) {Helper predicates} pred Neighbour(x::Nationality,y::Nationality,order::Order) iff {y is neighbour of x} x <> y & order(z1) = x & order(z2) = y & (z1 = z2 + 1 | z1 = z2 - 1) pred LeftOf(x::Nationality,y::Nationality,order::Order) iff {x is left of y} x <> y & order(z1) = x & order(z2) = y & z1 = z2 - 1
This page was created by F1toHTML