Skip to content

Einstein wrote this riddle this century. He said that 98% of the world could not solve it.

Notifications You must be signed in to change notification settings

engrbugs/Einstein.Riddle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Can you solve Einstein's Riddle?

This Python project will solve the riddle with the help of trial n' error and a little of AI. Check the code inside.

Source code click here

The Situation:

Click for explanation video

The Clues:

There are five houses in five different colors in a row. In each house lives a person with a different nationality. The five owners drink a certain type of beverage, smoke a certain brand of cigar and keep a certain pet. No owners have the same pet, smoke the same brand of cigar, or drink the same beverage. Other facts:

  1. The Brit lives in the red house.
  2. The Swede keeps dogs as pets.
  3. The Dane drinks tea.
  4. The green house is on the immediate left of the white house.
  5. The green house's owner drinks coffee.
  6. The owner who smokes Pall Mall owns birds.
  7. The owner of the yellow house smokes Dunhill.
  8. The owner living in the center house drinks milk.
  9. The Norwegian lives in the first house.
  10. The owner who smokes Blends lives next to the one who keeps cats.
  11. The owner who keeps the horse lives next to the one who smokes Dunhill.
  12. The owner who smokes Bluemasters drinks beer.
  13. The German smokes Prince.
  14. The Norwegian lives next to the blue house.
  15. The owner who smokes Blends lives next to the one who drinks water.

The question is: who owns the fish?

Computation:

Einstein.Riddly.py running on Pycharm IDE

The Process:

At first, the computer just follow all the clues given. If not on the data yet, just assume the data. This until all cluse are true. Check the computer log file. Output file here.


RUN TEST # 1 :

Data:
1 2 3 4 5
color RED empty empty empty empty
national BRIT empty empty empty empty
cigar empty empty empty empty empty
drink empty empty empty empty empty
pet empty empty empty empty empty
Data:
1 2 3 4 5
color RED empty empty empty empty
national BRIT empty empty SWEDE empty
cigar empty empty empty empty empty
drink empty empty empty empty empty
pet empty empty empty DOG empty
Data:
1 2 3 4 5
color RED empty empty empty empty
national BRIT DANE empty SWEDE empty
cigar empty empty empty empty empty
drink empty TEA empty empty empty
pet empty empty empty DOG empty
Data:
1 2 3 4 5
color RED empty empty GREEN WHITE
national BRIT DANE empty SWEDE empty
cigar empty empty empty empty empty
drink empty TEA empty empty empty
pet empty empty empty DOG empty
Data:
1 2 3 4 5
color RED empty empty GREEN WHITE
national BRIT DANE empty SWEDE empty
cigar empty empty empty empty empty
drink empty TEA empty COFFEE empty
pet empty empty empty DOG empty
Data:
1 2 3 4 5
color RED empty empty GREEN WHITE
national BRIT DANE empty SWEDE empty
cigar empty empty PALLMALL empty empty
drink empty TEA empty COFFEE empty
pet empty empty BIRD DOG empty
Data:
1 2 3 4 5
color RED YELLOW empty GREEN WHITE
national BRIT DANE empty SWEDE empty
cigar empty DUNHILL PALLMALL empty empty
drink empty TEA empty COFFEE empty
pet empty empty BIRD DOG empty
Data:
1 2 3 4 5
color RED YELLOW empty GREEN WHITE
national BRIT DANE empty SWEDE empty
cigar empty DUNHILL PALLMALL empty empty
drink empty TEA MILK COFFEE empty
pet empty empty BIRD DOG empty
Data:
1 2 3 4 5
color empty YELLOW empty GREEN WHITE
national NORWEGIAN DANE empty SWEDE empty
cigar empty DUNHILL PALLMALL empty empty
drink empty TEA MILK COFFEE empty
pet empty empty BIRD DOG empty
Data:
1 2 3 4 5
color empty YELLOW empty GREEN WHITE
national NORWEGIAN DANE empty SWEDE empty
cigar empty DUNHILL PALLMALL empty empty
drink empty TEA MILK COFFEE empty
pet empty empty BIRD DOG empty
Data:
1 2 3 4 5
color empty YELLOW empty GREEN WHITE
national NORWEGIAN DANE empty SWEDE empty
cigar empty DUNHILL PALLMALL empty empty
drink empty TEA MILK COFFEE empty
pet empty empty BIRD DOG empty
Data:
1 2 3 4 5
color empty YELLOW empty GREEN WHITE
national NORWEGIAN DANE empty SWEDE empty
cigar empty DUNHILL PALLMALL empty BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD DOG empty
Data:
1 2 3 4 5
color empty YELLOW empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty DUNHILL PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Data:
1 2 3 4 5
color empty BLUE empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty empty PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Data:
1 2 3 4 5
color empty BLUE empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty empty PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Data:
1 2 3 4 5
color empty BLUE empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty empty PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Data:
1 2 3 4 5
color empty BLUE empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty empty PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Data:
1 2 3 4 5
color empty BLUE empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty empty PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Data:
1 2 3 4 5
color empty BLUE empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty empty PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Data:
1 2 3 4 5
color empty BLUE empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty empty PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Data:
1 2 3 4 5
color empty BLUE empty GREEN WHITE
national NORWEGIAN DANE empty GERMAN empty
cigar empty empty PALLMALL PRINCE BLUEMASTER
drink empty TEA MILK COFFEE ROOTBEER
pet empty empty BIRD empty empty
Confirmed:
1 2 3 4 5
color 0 1 0 4 4
national 1 5 0 4 0
cigar 0 0 5 4 4
drink 0 5 1 4 4
pet 0 0 5 0 0
Connection1:
1 2 3 4 5
color 0 14 0 4 4
national 9 3 0 13 0
cigar 0 0 6 13 12
drink 0 3 8 5 12
pet 0 0 6 0 0
Until...
RUN TEST # 32 :
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD empty DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD FISH DOG
Data:
1 2 3 4 5
color YELLOW BLUE RED GREEN WHITE
national NORWEGIAN DANE BRIT GERMAN SWEDE
cigar DUNHILL BLENDS PALLMALL PRINCE BLUEMASTER
drink WATER TEA MILK COFFEE ROOTBEER
pet CAT HORSE BIRD FISH DOG
Confirmed:
1 2 3 4 5
color 1 1 1 1 1
national 1 1 1 1 1
cigar 1 1 1 1 1
drink 1 1 1 1 1
pet 1 1 1 1 1
Connection1:
1 2 3 4 5
color 7 14 1 4 4
national 9 3 1 13 2
cigar 7 15 6 13 12
drink 15 3 8 5 12
pet 15 7 6 20 2

The guy who steal the FISH is the GERMAN who has GREEN walls in his house, and likes to smoke PRINCE cigar. He also drinks COFFEE regularly.

Done Finish. In 32 runs.

About

Einstein wrote this riddle this century. He said that 98% of the world could not solve it.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages