|more useful options|
Solve Einstein's problem with perl?!by weini (Friar)
|on Feb 21, 2002 at 10:47 UTC||Need Help??|
Dear fellow monks,
being a novice I try to improve my skills by solving the following problem with perl. It is said to be invented by Albert Einstein who believed only 2 percent of the world population could solve it. He had no idea of perl or the monastery, of course ;^)
So here's the task:
1. There are five houses with different colours.
2. In each of the houses there lives a member of a different nation.
3. Each one of these people likes a special drink and a special cigarrette best and has a special pet.
4. None of the 5 persons likes the same drink or cigarrete best or has the same pet as one of his neighbours.
To whom belongs the fish?
The British lives in the red house.
I think of creating an array of five hashes (with the six keys: house_number, colour, drink, cigarette, pet, and nation). One could then fill out the known attributes and try to move the hashes around the array until each but one field is filled.
So far the thoughts of a poor brain ... Can anyone please tell me if this might be the right start and how to get on?
Having solved the problem by hand, there is another question: How comes, that the German doesn't drink beer? ;^) Thanks for your help!