River crossing¶
Logic and puzzles · level 2, lesson 5 of 6
A question to start¶
A farmer has a wolf, a goat and a cabbage. They are all on the left bank of a river, and they all need to get to the right bank. There is a little boat, but it is so small that it holds the farmer and only one other thing.
There is a problem. If the farmer leaves the wolf and the goat alone together, the wolf eats the goat. If he leaves the goat and the cabbage alone together, the goat eats the cabbage. (The wolf does not eat cabbage.) When the farmer is there, everyone behaves.
How can the farmer get everyone across, safely? Try it with three coins or scraps of paper before you read on. Most people get stuck the first time. The trick is something people forget they are allowed to do.
This puzzle is very old. One of the oldest written versions is in a collection of puzzles linked to Alcuin of York, a teacher who lived about 1200 years ago.
The idea¶
Writing down the rules¶
A puzzle like this is all about rules. Before trying anything, write them down clearly.
- The boat needs the farmer to row it. It never crosses by itself.
- The boat holds the farmer and at most one other thing.
- Wolf and goat must never be on a bank together without the farmer.
- Goat and cabbage must never be on a bank together without the farmer.
- Wolf and cabbage together are fine.
Notice that the goat is in both dangerous pairs. The goat is the troublemaker: it is either eaten or eating. That is a clue.
The first trip: try every choice¶
On the very first trip, the farmer has four choices. Let us check each one, by looking at what is left behind on the left bank.
- Take the wolf: goat and cabbage are left alone. The goat eats the cabbage. ✗
- Take the cabbage: wolf and goat are left alone. The wolf eats the goat. ✗
- Go alone: all three are left. Disaster. ✗
- Take the goat: wolf and cabbage are left. That is safe. ✓
So the first trip must be the goat. We did not guess: we tried every choice and only one survived. This is the same as the clue riddles from level 1: cross out what cannot work.
The trick: going back is allowed¶
After the goat is across, the farmer rows back alone (that is safe: the goat is alone on the right, and the wolf and cabbage are fine together on the left). Now he takes, say, the cabbage across.
Now there is a problem. If he rows back alone, the goat and the cabbage are left together on the right bank. ✗
Most people get stuck here. The trick: the farmer can take something back with him. He brings the goat back to the left bank! That feels like going backwards. But it is the key to the whole puzzle.
The whole answer, trip by trip¶
Here is every trip. After each one, check both banks: is any dangerous pair left without the farmer?
| Trip | Boat carries | Left bank | Right bank |
|---|---|---|---|
| start | farmer, wolf, goat, cabbage | ||
| 1 → | farmer and goat | wolf, cabbage | farmer, goat |
| 2 ← | farmer alone | farmer, wolf, cabbage | goat |
| 3 → | farmer and cabbage | wolf | farmer, goat, cabbage |
| 4 ← | farmer and goat | farmer, wolf, goat | cabbage |
| 5 → | farmer and wolf | goat | farmer, wolf, cabbage |
| 6 ← | farmer alone | farmer, goat | wolf, cabbage |
| 7 → | farmer and goat | farmer, wolf, goat, cabbage |
Check the dangerous moments. After trip 3, goat and cabbage are together on the right, but the farmer is there. ✓ After trip 5, the goat is alone on the left, and the wolf and cabbage are together on the right with the farmer. ✓ After trip 6, wolf and cabbage are alone together, and that is allowed. ✓
Seven trips, and everyone is safe.
A second answer¶
At trip 3 the farmer took the cabbage. He could have taken the wolf instead! Then: trip 4 brings the goat back, trip 5 takes the cabbage, trip 6 the farmer comes back alone, trip 7 takes the goat. That also works. The two answers are mirror images: the wolf and the cabbage swap jobs. That makes sense, because they play the same part in the puzzle: each is dangerous only with the goat.
Why it cannot be done in fewer than 7 trips¶
Every trip to the right carries at most one thing. Three things must get to the right, so that is at least 3 trips right. But we saw the goat must go first, and then the next thing to go over cannot be left with the goat, so the goat has to come back and cross a second time. So the trips to the right carry: goat, one thing, the other thing, and the goat again. That is 4 trips right.
Between two trips to the right, the farmer must row back to the left, so there are 3 trips left in between. 4 and 3 make 7. No answer can be shorter.
How to solve a crossing puzzle¶
- Write the rules, especially what cannot be left together.
- At each step, list the choices: who goes in the boat?
- For each choice, check both banks. Cross out choices that break a rule.
- Remember that bringing something back is a choice too.
- If you reach a dead end, go back to an earlier step and try a different choice.
- Keep a table, so you do not go round in circles.
Worked examples¶
Example 1. The grown-up and two children. A grown-up and two children need to cross a river. The boat holds one grown-up, or one or two children, but not a grown-up and a child together. Everyone can row. How do they all cross?
- If the grown-up goes first, someone has to bring the boat back, and the grown-up is the only one on the right. He comes straight back. That gets nowhere.
- So send both children first (trip 1).
- One child brings the boat back (trip 2).
- Now the grown-up crosses alone (trip 3). The other child is waiting on the right, with the boat now on the right.
- That child brings the boat back (trip 4).
- Both children cross together (trip 5).
5 trips. The children act as the boat's "taxi": every time the grown-up crosses, a child must bring the boat back.
Example 2. Two grown-ups and two children. Same boat. Repeat the pattern.
- Trips 1 to 4 are exactly as in Example 1, and the first grown-up crosses. Where are the children now? After trip 2 one child is on the left; after trip 4 the other child has rowed back too. So both children and the boat are on the left again, just like at the start.
- The first grown-up is now on the right. Do the same four trips again for the second grown-up: children cross, one child back, grown-up crosses, other child back (trips 5 to 8).
- Both children cross (trip 9).
9 trips. Each grown-up costs 4 trips, and the final trip brings the children. The key check was step 1: the children end up back where they began, so the same four trips can be used again.
Example 3. A bigger boat. Back to the farmer, but now the boat holds the farmer and two things.
- Take the wolf and the cabbage (trip 1). The goat is left alone on the left: safe.
- Come back alone (trip 2). The wolf and cabbage are together on the right: safe.
- Take the goat (trip 3).
3 trips. A bigger boat changes everything. The rules of a puzzle decide how hard it is.
Try it¶
- Explain why the farmer cannot take the wolf on the first trip.
- In the 7-trip answer, what goes wrong if the farmer does not bring the goat back at trip 4?
- Write out the second answer (the one where the wolf crosses at trip 3), trip by trip.
- A girl must take a fox, a chicken and a bag of corn across a river, with a boat that holds her and one thing. The fox eats the chicken, and the chicken eats the corn. How is this the same as the farmer's puzzle?
- What if the wolf ate the cabbage too? (So every pair is dangerous.) Can the farmer still do it with the small boat? Explain.
- Three grown-ups and two children, with the same boat as Example 1. How many trips? Can you see a pattern for 1, 2, 3 grown-ups?
- Why does the farmer never need to take the wolf back to the left bank?
Answers
- If he takes the wolf, the goat and the cabbage are left together on the left bank without him, and the goat eats the cabbage.
- He has just put the cabbage (or the wolf) on the right bank with the goat. If he rows back alone, the goat and that thing are left together, and something gets eaten. Rowing back with the goat is the only safe choice.
- Trip 1: farmer takes the goat over. Trip 2: farmer comes back alone. Trip 3: farmer takes the wolf over. Trip 4: farmer brings the goat back. Trip 5: farmer takes the cabbage over. Trip 6: farmer comes back alone (wolf and cabbage are safe together). Trip 7: farmer takes the goat over. 7 trips.
- The fox plays the wolf, the chicken plays the goat, and the corn plays the cabbage. The dangerous pairs are the same shape: the chicken is in both. So the same answer works: chicken over, back alone, fox over, chicken back, corn over, back alone, chicken over. 7 trips.
- No. On the first trip he can take only one thing, so two things are left behind on the left bank, and every pair is dangerous. Something is always eaten. (Going alone leaves three, which is worse.) There is no safe first trip, so it cannot be done.
- Each grown-up needs 4 trips (children cross, one child back, grown-up crosses, other child back), and then 1 last trip for the children. 1 grown-up: 4 and 1 make 5. 2 grown-ups: 8 and 1 make 9. 3 grown-ups: 12 and 1 make 13. The pattern goes up by 4 for each extra grown-up.
- Taking something back is only useful to stop it being left with the goat. The wolf on the right bank is only in danger with the goat, and the farmer can always take the goat back instead. Bringing the goat back fixes the problem, because the goat is the troublemaker.
Common mistake¶
Thinking the boat must always carry something forward. People try only moves that take things to the right bank, and they get stuck after trip 3. The rules never say you cannot bring something back. Read the rules for what they say, not for what you expect.
Checking only one bank. After each trip, check both banks. A trip can make the side you left safe and the side you arrived at dangerous, or the other way round.
Where it leads¶
- Previous lesson: Coding with steps. Next lesson: Logic grid puzzles.
- This level: Level 2: Rules and puzzles. The whole topic: Logic and puzzles.
- Keeping a careful list of every choice is how you count all the ways to do something: Being organised in Counting.
- Going back to an earlier step and trying another choice is a real method that computers use to solve puzzles, like Sudoku: 4-by-4 Sudoku.
- The grown-ups pattern (5, 9, 13, going up by 4) is a growing pattern: Rules in words in Patterns.
- In level 4 you will work backwards from the end to win games: Level 4.