It is currently Tue Oct 06, 2015 10:43 pm

 All times are UTC

 Post new topic  Reply to topic Page 1 of 1 [ 9 posts ]
 Print view Previous topic | Next topic
Author Message
 Post subject: who ownes the zebraPostPosted: Fri Mar 08, 2013 1:12 pm
 Level 1 Cleric

Joined: Mon Aug 31, 2009 11:21 am
Posts: 12
i want to solve this by computer :
Quote:
''1.There are five houses.
''2.The Englishman lives in the red house.
''3.The Spaniard owns the dog.
''4.Coffee is drunk in the green house.
''5.The Ukrainian drinks tea.
''6.The green house is immediately to the right of the ivory house.
''7.The Old Gold smoker owns snails.
''8.Kools are smoked in the yellow house.
''9.Milk is drunk in the middle house.
''10.The Norwegian lives in the first house.
''11.The man who smokes Chesterfields lives in the house next to the man with the fox.
''12.Kools are smoked in the house next to the house where the horse is kept.
''13.The Lucky Strike smoker drinks orange juice.
''14.The Japanese smokes Parliaments.
''15.The Norwegian lives next to the blue house

''who ownes the zebra ?

i cant use brute force
this has pow( 5! , 5 ) = 24883200000 posebilities

_________________
cxiu diferas el tio respondas cxiu samvaloras
[ esperanto for : everybody is diferent therefore everybody is equal ]

Top
 Post subject: Re: who ownes the zebraPostPosted: Fri Mar 08, 2013 8:19 pm
 Grand Optimizer

Joined: Sun Oct 16, 2011 3:09 pm
Posts: 367
Location: Here (where else?)
Indeed, a much better strategy is to use the clues directly, and use logic deduction, much like we do.
eg Englishman <-> red house

-> not Englishman <-> green house
not Englishman <-> ivory house
not Englishman <-> yellow house
not Englishman <-> blue house
not Spaniard <-> red house
not Ukrainian <-> red house
not Japanese <-> red house
not Norwegian <-> red house

It's a fun puzzle to figure out how to program deduction

_________________
My project: Messing about in FreeRCT, dev blog, and IRC #freerct at oftc.net

Top
 Post subject: Re: who ownes the zebraPostPosted: Fri Mar 08, 2013 9:34 pm
 Dexterous Droid

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3871
Location: South Africa
This would be much easier to solve with pen and paper. But I'll take a crack at the groundwork.

I would start out with identifying the kinds of logical relations.
• x implies y
• x is next to y
• x to the right of y
• x is in house number i
Then one needs to identify what house attributes are available and their possible values.
• colour: red green blue yellow ivory
• pet: dog snail fox horse [implied zebra]
• smoke: Old Gold, Kools, Chesterfield, Lucky Strike, Parliaments
• drink: coffee tea milk OJ [implied gin & tonic, obviously]
• nationality: English, Ukrainian, Spanish, Norwegian, Japanese
From the standpoint of the puzzle, houses are an array of containers for the above attributes (house number, colour, etc).

The first step is to put down things that can't change, the rules which specify house number should be applied as well as any that can be directly applied (in this case just that the blue house is next to the Norwegian, there aren't any other direct relations).
Code:
`number                  |   1             |   2             |   3             |   4             |   5             |colour                  |                 | blue            |                 |                 |                 |pet                     |                 |                 |                 |                 |                 |smoke                   |                 |                 |                 |                 |                 |drink                   |                 |                 | milk            |                 |                 |nationality             | norwegian       |                 |                 |                 |                 |`

The puzzle doesn't have any other rules we can apply directly so we need to eliminate the possible options in each cell until only 1 option remains. Referring to our logical relations, the ways of eliminating options are:
• x implies y: (1) eliminate x from all houses that are not y, vice-versa for y.
• x is next to y: (1) where either x or y is known, eliminate the other from all cells not next to the known one.
• x to the right of y: (1) eliminate x where a value to the left is known to be not y. eliminate y where a value to the right is known to be not x. (2) eliminate y from all the right-most houses, eliminate x from all the left-most houses

There might be a bunch of others but from here you can infer
1. house 1 has the norwegian, so by the first rule we can eliminate all the options involving nationality. -red, -tea, -parliament
2. eliminate green from house 1 because it's the left-most house.
3. eliminate ivory from hosue 1 because it's to the left of a known blue house.
3. the only colour left is yellow, so the first house is yellow.

If you carry on eliminating options then you should arrive at a solution. You just need to make sure that the list of methods to eliminate options is complete. So the general algorithm is:
Code:
`while there are still unkown values in houses{   check if any of the rules can be applied directly, without inference   eliminate potential values from all the houses until one of the attributes only has 1 possible value left}`

_________________
Whatever the mind can conceive and believe, it can achieve

Top
 Post subject: Re: who ownes the zebraPostPosted: Fri Mar 29, 2013 5:38 am
 Technomaniac

Joined: Sun Dec 05, 2004 11:27 am
Posts: 3252
Location: Sydney, Australia
Just looking at the clues, there is no indication that anyone owns a zebra. Are you sure this isn't a trick question?

If you are looking for an interesting programming language for this sort of thing, have a look at prolog. It should let you do something which will mean that each clue translates fairly directly into the language, and then you can ask it questions (like who owns the zebra) and it will give you an answer (or tell you that it can't work out the answer from the clues)

_________________
Trying is the first step towards failure
b

Top
 Post subject: Re: who ownes the zebraPostPosted: Fri Mar 29, 2013 1:06 pm
 Dexterous Droid

Joined: Wed Aug 18, 2004 7:40 pm
Posts: 3871
Location: South Africa
Andy wrote:
Just looking at the clues, there is no indication that anyone owns a zebra. Are you sure this isn't a trick question?

You're right. It should have stated, "given that someone owns a zebra, who is it?". There's also an unkown drink.

_________________
Whatever the mind can conceive and believe, it can achieve

Top
 Post subject: Re: who ownes the zebraPostPosted: Thu Apr 04, 2013 9:09 am
 Postronaut

Joined: Sun Mar 10, 2013 3:32 pm
Posts: 45
i own a zebra..

Top
 Post subject: Re: who ownes the zebraPostPosted: Thu Apr 04, 2013 5:28 pm
 BANNED

Joined: Sun Jun 24, 2012 12:49 am
Posts: 504
Hey, I was going to say that! I own the Zebra!

Top
 Post subject: Re: who ownes the zebraPostPosted: Fri Apr 05, 2013 5:43 pm
 411 Operator

Joined: Sun Aug 05, 2012 9:32 pm
Posts: 420
From what i can tell by looking at the clues, there are 5 houses, and 4 animals mentioned, if you figure out who owns what, you will find out who owns the zebra

_________________
Did you ever wonder, how time works?

Top
 Post subject: Re: who ownes the zebraPostPosted: Sun Apr 07, 2013 9:17 pm
 411 Operator

Joined: Sun Aug 05, 2012 9:32 pm
Posts: 420
So did you manage to make the algorithm for finding out who owns the zebra? I am really thrilled to know the answer I think its the Norwegian, he seems like the type that would steal a zebra from a ZOO

_________________
Did you ever wonder, how time works?

Top
 Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending
 Post new topic  Reply to topic Page 1 of 1 [ 9 posts ]

 All times are UTC

#### Who is online

Users browsing this forum: Yahoo! [Bot] and 1 guest

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forum

Search for:
 Jump to:  Select a forum ------------------ Forums    Forum Rules and Posting Guidelines Wiki Discussion    Help    Content Issues Game Programming Discussion    C and C++ Game Programming    Java Game Programming    Language Agnostic Programming    .NET Game Programming    Mobile Game Programming    Web-Based Game Programming    Other Languages    OpenGL Development    Direct X Development Game Development Discussion    Game Design    Game Media Off-Topic Discussion    Announcements    Off-Topic    Community Projects    News