# The boatman, the wolf, the goat and the cabbage

This is a classic puzzle with more than 1000 years old. You can find more information on Wikipedia

A long time ago a farmer went to the market and bought a wolf a goat and a cabbage. To return home he had to cross a river where he had a boat to cross to the other shore but with the inconvenience that only he and one of his purchases fit in the boat.

He knows that if the wolf is left alone on the shore with the goat he will eat it and if the goat is left alone with the cabbage he will eat it.

The farmer's challenge is to cross himself and his purchases to the other side of the river, preventing the wolf from being left alone with the goat and eating it or that the goat is left alone with the cabbage and eating it.

As it did?

#### Solution

The first obligatory step consists in taking the goat through the river since otherwise the goat or the cabbage would be devoured. When the farmer returns to the first shore he can choose between taking the wolf or the cabbage to the other side. If you carry the wolf you must return later to bring the cabbage, then the wolf would eat the goat since it would only stay with the goat on the second shore.

If instead he takes the cabbage to the other shore he will need to return to catch the wolf and then the cabbage would be eaten by the goat that would have been left alone with her on the shore.

Here is the dilemma that is solved by carrying the wolf (or cabbage) on the second trip and bringing the goat back. Now we can take the cabbage (or the wolf) leaving the goat and finally look for the goat again.

The solution is summarized as follows:
⇒ Leave the goat on the other side
⇐ Come back alone
⇒ Leave the wolf (or cabbage) on the other side
⇐Return with the goat
⇒ Leave the cabbage (or wolf) on the other side
⇐ Come back alone
⇒ Leave the goat on the other side