go ahead... be a heretic PerlMonks

comment on

 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 ;^)

--8<--8<--snip--8<--8<--

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.

Question:

To whom belongs the fish?

Hints:

The British lives in the red house.
The Swedish has a dog.
The Danish likes tea.
The green house is standing left of the white house.
The owner of the green house drinks coffee.
The person smoking Pall Mall, has a bird.
The man living in the middle house, drinks milk.
The owner of the yellow house smokes Dunhill.
The Norwegian lives in the first house.
The Marlboro-smoker's neighbour has a cat.
The man with the horse lives next to the Dunhill-smoker.
The Winfiels-smoker drinks beer.
The Norwegian lives beneath the blue house.
The German smokes Rothmanns.
The Marlboro-smoker has a neighbour who drinks water.

--8<--8<--snap--8<--8<--

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!

In reply to Solve Einstein's problem with perl?! by weini

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

• Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
• Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
• Read Where should I post X? if you're not absolutely sure you're posting in the right place.
• Please read these before you post! —
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
• You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
 For: Use: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?
• See Writeup Formatting Tips and other pages linked from there for more info.
• Log In?
 Username: Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2020-08-07 13:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Which rocket would you take to Mars?

Results (45 votes). Check out past polls.

Notices?