Happy Monday!
Today's problem will be to breakdown a common logic puzzle and write a program that can solve it.
A goat, a wolf and a bag of rice are on one side of a river and you need to get them to the other side using your canoe. You can carry one item in your canoe to the other side at any given time. However, when the goat and the wolf are left alone the wolf will eat the goat. If the goat and the bag of rice are left alone the goat will eat the bag of rice. As long as you are with them nothing will happen, i.e. the wolf won’t eat the goat and the goat won’t eat the bag of rice.
Can you come up with an algorithm that determines an order in which you can carry them all to the other side.
Comments:
Akshay Bist - 10 years, 1 month ago
reply permalink
Max Burstein - 10 years, 1 month ago
Definitely the correct approach. Can you think up a way to represent that with code so that we could change out the characters if we wanted to?
reply permalink