A farmer is on the south bank of a river with his possessions: a goat, a wolf, a
ID: 3559710 • Letter: A
Question
A farmer is on the south bank of a river with his possessions: a goat, a wolf, and a very large cabbage. The farmer wants to get to the north shore of the river with all of his possesions. The river is too deep and wide to wade across. However, there is a small boat available. The boat is so small that the farmer can only take one of his pocessions at a time. It is important to note two other conditions. First, if the goat and the wolf are left alone on the same side of the rover, the wolf will eat the goat. And second, if the goat and the cabbage are left alone on the same side, the goat will eat the cabbage.
Help the farmer by telling him how he should move his possessions to get them all to the north side of the river. Develop two solutions one that uses breadth first search and one that uses depth first search. To help understanding the algorithm print each decision that is considered and either rejected or executed.
Explanation / Answer
FarmerWolfGoatRiddle.groovy
FarmerWolfGoatRiddleTest.groovy
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.