Get in touch with us
Send us an e-mail
Question
Write a program to solve the classic “Einstein Riddle”. You can use Java, Python, R, C/C++.
Einstein’s Riddle
This classic riddle is claimed to have been written by Einstein but it is sometimes also attributed to Lewis Carrol, although there's no evidence that either of them actually wrote it. Regardless, it is an interesting problem that can be solved by logic but it also lends itself nicely as an AI programming exercise. There are many ways to code for this riddle – you are free to choose any approach you want. The riddle is:
There are five houses in five different colours 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 rears birds.
The owner of the yellow house smokes Dunhill.
The owner living in the centre 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?
Summary
This question belongs to programming and discusses about solving a classic Einstein’s riddle using programming.
Download Full Solution
The best part about the assignments is the quality of writing that I have received every time. The “real world†examples collated locally from Singapore suggested by the online management assignment tutors with the corresponding requisite numbers help take the assignment several notches higher and have helped improve my grades.
I was a bad place with my electricity assignment and was not sure how to apply the laws to get the numerical assignments done. Then I came in contact of one of my seniors in my college who told me about HwA. The service I got here was awesome and more than giving me a A in my assignment they also treated me with respect and helped me learn a lot.
The experience is wonderful and more importantly I enjoyed the warmth with which they welcomed me and addressed my marketing management problem. The experts here are from Australia itself and not someone sitting in UK and USA, not having any knowledge about the Australian market.
Operations management was my minor during my MBA but I faced much challenges with the problems and assignments. So once when I was stuck with my supply chain management assignment my friend Joan told me about this website. The feedback I got from them was very positive and the assignment was also very well done. All the calculations and the charts were displayed in proper manner and from then onwards I constantly took help from them.
I had an optical networking assignment due along with two other assignments due around the same time. I was just not getting enough time to give for dedicated research on the optical networking assignment. I just wished that someone could take the responsibility of conducting the research on my behalf and structure the assignment also. One of my friends was using TheReliableTutor.com and told me to give it a go. I was so impressed by their quality and service standard that I have become a repeat customer.
Comments
this is a very good website
I have 50 questions for the same test your page is showing only 28
hi can you please help or guide me to answer my assignments. thanks
hi can anyone help or guide me to my assignments. thanks
This solution is perfect ...thanks
Hello Allison,I love the 2nd image that you did! I also, had never heard of SumoPaint, is something that I will have to exolpre a bit! I understand completely the 52 (or so) youtube videos that you probably watched. Sometimes they have what you want, sometimes they don't! However, it is always satisfying when you are able to produce something that you have taught yourself. Great job!Debra 0 likes
Perfect bank of solution.
great !
thanks for the quick response. the solution looks good. :)
thnx for the answer. it was perfect. just the way i wanted it.
works fine.