Who drinks water and who owns the zebra




















The Ukrainian drinks tea. The green house is immediately to the right of the ivory house to your right as you stand facing the row of five houses. The Old Gold smoker owns snails.

Kools are smoked in the yellow house. Milk is drunk in the middle house. The Norwegian lives in the first house. The man who smokes Chesterfields lives in the house next to the man with the fox. Kools are smoked in a house next to the house where the horse is kept. The Lucky Strike smoker drinks orange juice. The Japanese smokes Parliaments. The Norwegian lives next to the blue house. We know that the Englishwoman lives in the red house, so we can transfer that data to our chart. We also know that the Spaniard owns a dog, so again we can add that data.

By following this data, we can slowly build a complete list of information. This gives us the following facts…. This free energiser is great for use as a stand-alone logic puzzle, or it can be included in a wider problem solving training course. Subscribe to the Trainer Bubble mailing list to receive updates on new products, special offers and all the latest industry news sent right to your inbox. Download Now. Duration: 30 minutes.

Resources Needed: A set of instructions for each participant. Set Up: Explain to the participants that you will be giving them a set of instructions to help solve a logic and problem solving puzzle.

The participants task is to resolve the puzzle in as quick a time as possible. Instructions: Use your powers of deduction to answer the questions at the bottom of this page. The Englishwoman lives in the red house. The Spaniard owns a dog. Coffee is drunk in the greenhouse 4. The Ukrainian drinks tea. Prolog is a logic programming language and associated interpreter that form such a system. It basically allows concluding of facts from statements made using First Order Logic.

FOL is basically a more advanced form of propositional logic. If you decide you don't want to use Prolog, you could use a similar system of your own creation using a technique such as modus ponens to perform the draw the conclusions.

You will, of course, need to add some rules about zebras, since it isn't mentioned anywhere I believe the intent is that you can figure out the other 4 pets and thus deduce the last one is the zebra? You'll want to add rules that state a zebra is one of the pets, and each house can only have one pet. Getting this kind of "common sense" knowledge into an inference system is the major hurdle to using the technique as a true AI. There are some research projects, such as Cyc, which are attempting to give such common knowledge through brute force.

They've met with an interesting amount of success. Then I'd filter out the simple boolean conditions. Of course they're not independent but after filtering those out there shouldn't be many left. After that, you've got a nice graph problem. Create a graph with each node representing one of the remaining n-tuples.

Add edges to the graph if the two ends contain duplicates in some n-tuple position or violate any 'positional' constraints there's five of those. From there you're almost home, search the graph for an independent set of five nodes with none of the nodes connected by edges. If there's not too many, you could possibly just exhaustively generate all the 5-tuples of n-tuples and just filter them again.

This could be a good candidate for code golf. Someone can probably solve it in one line with something like haskell :. Granted, it's more verbose than using Python's "constraint" module in the solution by J. Sebastian, but it provides an interesting comparison for anybody looking into a raw knowledge engine for this type of problem.

With lots of ES6 generators and a little bit of lodash. You will need Babel to run this. Run time is around 2. I decided to keep the original order for clarity. This is really a constraint solving problem. You can do it with a generalized kind of constraint propagation in logic-programming like languages. We have a demo specifically for the Zebra problem in the ALE attribute logic engine system:.

The easiest way to solve such problems programmatically is to use nested loops over all permutations and check to see if the result satisfies the predicates in the question. Many of the predicates can be hoisted from the inner loop to outer loops in order to dramatically reduce the computational complexity until the answer can be computed in a reasonable time.

Here is a simple F solution derived from an article in the F Journal :. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Solving "Who owns the Zebra" programmatically? Ask Question. Asked 12 years, 11 months ago. Active 1 year, 1 month ago. Viewed 26k times.

Edit: this puzzle is also known as "Einstein's Riddle" The Who owns the Zebra you can try the online version here is an example of a classic set of puzzles and I bet that most people on Stack Overflow can solve it with pen and paper.

Based on the clues listed below There are five houses. Each house has its own unique color. All house owners are of different nationalities. They all have different pets. They all drink different drinks.

They all smoke different cigarettes. The English man lives in the red house. The Swede has a dog. The Dane drinks tea. The green house is on the left side of the white house. They drink coffee in the green house.

The man who smokes Pall Mall has birds. In the yellow house they smoke Dunhill.



0コメント

  • 1000 / 1000