Einstein's problem and a solution by elimination

By Christian Stigen Larsen
01 Jan 2008

The Zebra Puzzle is a famous puzzle that has been said to have been invented by Einstein. It is not. Neither is it true that only 2% of people can solve it. But it *is* a very fun puzzle and I invite everyone to try to solve it on their own. Below I sketch out how I did it.

The Puzzle

  • There are five houses in unique colors: Blue, green, red, white and yellow.
  • In each house lives a person of unique nationality: British, Danish, German, Norwegian and Swedish.
  • Each person drinks a unique beverage: Beer, coffee, milk, tea and water.
  • Each person smokes a unique cigar brand: Blue Master, Dunhill, Pall Mall, Prince and blend.
  • Each person keeps a unique pet: Cats, birds, dogs, fish and horses.

The following facts are given:

  1. The Brit lives in a red house.
  2. The Swede keeps dogs as pets.
  3. The Dane drinks tea.
  4. The green house is on the left of the white, next to it.
  5. The green house owner drinks coffee.
  6. The person who smokes Pall Mall rears birds.
  7. The owner of the yellow house smokes Dunhill.
  8. The man living in the house right in the center drinks milk.
  9. The Norwegian lives in the first house.
  10. The man who smokes blend lives next to the one who keeps cats.
  11. The man who keeps horses lives next to the man who smokes Dunhill.
  12. The owner who smokes Blue Master drinks beer.
  13. The German smokes Prince.
  14. The Norwegian lives next to the blue house.
  15. The man who smokes blend has a neighour who drinks water.

The question you need to answer is: Who keeps fish?

Try to work on this problem yourself before looking at the solution! It is really not that hard once you find a good approach.

A Solution

Given facts 8 and 9, we can safely assume that the houses are positioned in a row. This lets us set up a table to hold all the information we find.

We will use the following codes for the various pets, cigar brands and so on:

  • blue, green, red, white, yellow
  • british, danish, german, norwegian, swede
  • beer, coffee, milk, tea, water
  • blue master, dunhill, pall mall, prince, blend
  • birds, cats, dogs, fish, horses

Instead of starting with an empty table and filling in the possible values, I found it much easier to just insert all possibilities up front. We will then eliminate possible values in each cell as we read the facts. This can easily be done with pen and paper.

Colour bgrwy bgrwy bgrwy bgrwy bgrwy
Nationality bdgns bdgns bdgns bdgns bdgns
Beverage bcmtw bcmtw bcmtw bcmtw bcmtw
Cigar bdprl bdprl bdprl bdprl bdprl
Pet bcdfh bcdfh bcdfh bcdfh bcdfh

First up we simply eliminate possibilities by using facts 8, 9 and 10.

Colour grwy b grwy grwy grwy
Nationality n bdgs bdgs bdgs bdgs
Beverage bctw bctw m bctw bctw
Cigar bdprl bdprl bdprl bdprl bdprl
Pet bcdfh bcdfh bcdfh bcdfh bcdfh

The Brit lives in a red house (fact 1), so remove colour option r from all houses which doesnt have brit as a possible nationality.

Colour gwy b grwy grwy grwy
Nationality n dgs bdgs bdgs bdgs
Beverage bctw bctw m bctw bctw
Cigar bdprl bdprl bdprl bdprl bdprl
Pet bcdfh bcdfh bcdfh bcdfh bcdfh

Fact 4 says the green house is on the left side, next to the white. So the first house cannot be green or white, leaving yellow as the only possibility. The last house cannot be green. By fact 5, remove green as an option for the center house. This house also cannot be white, due to fact 4, leaving the colour red. This also leads us to conclude that the second and last houses are green and white, respectively.

We can now insert b for Brit in the red house.

Colour y b r g w
Nationality n dgs b dgs dgs
Beverage btw btw m c btw
Cigar bdprl bdprl bdprl bdprl bdprl
Pet bcdfh bcdfh bcdfh bcdfh bcdfh

Continuing with fact 3, we remove the Dane as an option for the green house. Also remove tea from the first house. Fact 2 says the Swede keeps dogs, so remove d for dogs in all houses which doesn't have Swede as an option. Fact 7 says the Norwegian smokes Dunhill, and fact 10 says the next house keeps horses.

Fact 12 says the one smoking Blue Master drinks beer, so remove b from all houses that don't match — therefore the Norwegian must drink water. We will also remove b for Blue Master in houses that doesn't have a beer option.

The Swede keeps dogs, so remove s for Swede from the blue house, which has horses.

Colour y b r g w
Nationality n dg b gs dgs
Beverage w bt m c bt
Cigar d bprl prl prl bprl
Pet bcf h bcf bcdf bcdf

As you can see, this puzzle is quite trivial to solve once we have a good approach. Just keep chipping away at the problem, removing possible values for each cell.

Fact 15 means that the blend (l) is smoked in the second house, so update the table according to this. Fact 6 says the first house cannot have a bird option, as Dunhill is smoked there. Fact 13 forces us to remove the German option for the second house, since blend is smoked there. Fact 3 again gives us tea for this house, and this leaves beer for the last house.

Fact 10 means the Norwegian keeps cats.

Colour y b r g w
Nationality n d b gs gs
Beverage w t m c b
Cigar d l pr pr bpr
Pet c h bf bdf bdf

Now everything falls into place. We will now skip all the intermediate steps and just show you the final table.

Colour y b r g w
Nationality n d b g s
Beverage w t m c b
Cigar d l p r b
Pet c h b f d