Overview
The wolf, goat and cabbage puzzle is one of the oldest recorded river-crossing riddles, appearing in a manuscript from around the 9th century. A farmer must ferry three things across a river in a boat that holds only one at a time, while two of the pairings are deadly if left unsupervised.
It is a classic search problem: each bank configuration is a state, and each safe crossing is a move between states. The trick that makes people stumble is realising that sometimes you have to bring something back.
How to solve Wolf, Goat & Cabbage
- Note the two forbidden pairings: wolf + goat, and goat + cabbage. The goat is the troublemaker in both, so it can never be left with either of the others.
- Take the goat across first — the wolf and cabbage are safe together — then return alone.
- Take the wolf across, but bring the goat back so it is never left with the wolf.
- Take the cabbage across (leaving the goat on the near bank), then return alone.
- Finally take the goat across. All three are delivered in seven crossings.
The key insight
The move nobody expects is bringing the goat back on the third trip. A solution isn't a straight line of progress — undoing a step can be the only way forward, which is exactly how graph search escapes dead ends.
Variations & echoes
- The missionaries and cannibals puzzle is the same idea with a numeric safety constraint instead of pairings.
- It models any transport problem where intermediate states are dangerous — such as loading incompatible chemicals.
- The state graph has only a handful of nodes, so breadth-first search finds the seven-move optimum instantly.
Frequently asked questions
Is seven crossings the minimum?
Yes. There are two symmetric optimal solutions (starting the goat either way round the later trips), both taking exactly seven crossings.
Why can't the wolf and cabbage be left together?
Wolves don't eat cabbage and cabbages don't threaten wolves, so that pairing is always safe — which is what makes the very first move possible.