Einstein wrote a riddle. He said that 98% of the world could not solve it.
I solved this riddle in about 25 minutes while on the train to work. It's basically just deduction.
There are 5 houses in 5 different colors in a row.
In each house lives a person with a different nationality.
The 5 owners drink a certain type of beverage, smoke a certain brand of cigar, and keep a certain pet.
No owners have the same pet, smoke the same brand of cigar, or drink the same beverage.
Question: Who owns the fish?
To solve this riddle Einstein provides 15 hints:
- The Brit lives in the red house.
- The Swede keeps dogs as pets.
- The Dane drinks tea.
- The green house is on the immediate left of the white house.
- The green house's owner drinks coffee.
- The owner who smokes Pall Mall rears birds.
- The owner of the yellow house smokes Dunhill.
- The owner living in the center house drinks milk.
- The Norwegian lives in the first house.
- The owner who smokes Blends lives next to the one who keeps cats.
- The owner who keeps the horse lives next to the one who smokes Dunhill.
- The owner who smokes Bluemasters drinks beer.
- The German smokes Prince.
- The Norwegian lives next to the blue house.
- The owner who smokes Blends lives next to the one who drinks water.
With these hints you can come to a solution.
Your task: Make a program that will solve this riddle for you. Hard coding the solution isn't allowed (duh)
It is allowed to hardcode the hints in any format.
//Hints in order (Nationality:Brit)==(Color:Red) (Nationality:Swede)==(Pet:Dogs) (Nationality:Dane)==(Drink: Tea) (Color:Green)/(Color:White) (Color:Green)==(Drink:Coffee) (Smoke:PallMall)==(Pet:Birds) (Color:Yellow)==(Smoke:Dunhill) (House:3)==(Drink:Milk) (Nationality:Norwegian)==(House:1) (Smoke:Blend)/\(Pet:Cats)
== means equals to
/ means on left side of
\ means on right side of
/\ means left or right of
Like I said its allowed to either hardcode hints or have them as input.
Output: Output should be in the following format (With the correct values, just saying for the trolls ;) )
_____________ _____________ _____________ _____________ _____________ | Number | | Number | | Number | | Number | | Number | | Nationality | | Nationality | | Nationality | | Nationality | | Nationality | | Color | | Color | | Color | | Color | | Color | | Drink | | Drink | | Drink | | Drink | | Drink | | Smoke | | Smoke | | Smoke | | Smoke | | Smoke | | Pet | | Pet | | Pet | | Pet | | Pet | --------------- --------------- --------------- --------------- --------------- The <Nationality> in the <Color> house owns the fish!
Ascii art boxes can be changed by you, as long as they are boxes, doesn't matter what symbols you use.
Any knowledge on this riddle and solution can not be used in the program. It should use pure logic and deduction to solve the riddle.
Tagged this as a codegolf but might be a code challenge, not sure. Any thoughts on winning criteria for a code challenge feel free to share :)
For now this is code-golf so the program with the lowest bytecount wins.
Good luck and Happy coding :)