This Python project will solve the riddle with the help of trial n' error and a little of AI. Check the code inside.
Click for explanation videoThere 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:
- The Brit lives in the red house.
- The Swede keeps dogs as pets.
- The Dane drinks tea.
- The green house is on the immediate left of the white house.
- The green house's owner drinks coffee.
- The owner who smokes Pall Mall owns birds.
- The owner of the yellow house smokes Dunhill.
- The owner living in the center house drinks milk.
- The Norwegian lives in the first house.
- The owner who smokes Blends lives next to the one who keeps cats.
- The owner who keeps the horse lives next to the one who smokes Dunhill.
- The owner who smokes Bluemasters drinks beer.
- The German smokes Prince.
- The Norwegian lives next to the blue house.
- The owner who smokes Blends lives next to the one who drinks water.
The question is: who owns the fish?
Einstein.Riddly.py running on Pycharm IDEAt 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 |
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.