GenerateRandomSearch

River Crossing Puzzle

In a river-crossing puzzle everyone has to get across in a small boat, and some of them cannot be left together. This sets out each puzzle's rules exactly: who can row, how many the boat holds, and who may not be left with whom. It then searches every arrangement that can arise, so it can say whether the crossing is possible, the fewest crossings it takes, and how many different shortest ways there are. Play it here with undo, or print a worksheet with the solution on its own page.

What this generator does

Models each puzzle as kinds of passenger, the boat's seats, who can row, and rules about who may not be left together. An arrangement is how many of each kind are on the left bank and which side the boat is on, so every arrangement can be listed. A breadth-first search from the start then finds the fewest crossings and counts every shortest solution; when the far bank cannot be reached, it says how many arrangements it went through before running out.

How to use this tool

  1. Choose a puzzle; for shepherds and wolves, choose how many pairs and how many seats the boat has.
  2. Tick who crosses and press Cross. A crossing that breaks a rule is refused with the reason.
  3. Undo or start again at any time, open the shortest solutions, or print the worksheet and a solution.

Understanding the controls

Puzzle
Farmer, wolf, goat and cabbage (traditional); a picnic and a garden (written for this site); or shepherds and wolves, the traditional numbers rule on our own theme.
Pairs and boat seats
For shepherds and wolves: 1 to 6 pairs and a boat for 2, 3 or 4. Some settings are impossible, and the page shows why.
Who crosses now?
Tick who goes, or choose how many of each. Someone who can row must be aboard.

Worked examples

Farmer, wolf, goat and cabbage
7 crossings, and exactly two shortest ways: take the goat over, come back, take the wolf (or the cabbage), bring the goat back, take the cabbage (or the wolf), come back, take the goat.
Shepherds and wolves, boat for 2
1 pair: 1 crossing. 2 pairs: 5. 3 pairs: 11. 4 or more pairs: impossible, however the crossings are arranged.

Common use cases

  • A classic logic puzzle for a class, with the rules written out and the fewest crossings known
  • Comparing settings: why three pairs of shepherds and wolves can cross in a boat for two and four pairs cannot
  • A printable worksheet with a table to fill in and the solution separate

How this generator works

After every crossing both banks are checked, and the passengers who have just arrived count on the bank they reach. A move is allowed if the boat carries between one passenger and its full number of seats, including someone who can row, and both banks then obey every rule. Breadth-first search visits arrangements in order of how many crossings they take, so the first time it reaches everyone across is the fewest possible; counting the ways into each arrangement gives the number of shortest solutions. A separate check replays solutions with every person named and the rules tested in words, and a second, deepening search confirms each minimum in the tests.

Randomness and fairness

Nothing here is random: each puzzle is fixed, and the same settings always give the same analysis.

For how randomness is produced across the whole site, see how Generate Random works.

Assumptions this tool makes

  • The rules apply on the banks, not in the boat, and someone must row every crossing, including the way back.

Limitations and good to know

  • Four puzzle families only; you cannot write your own rules here.
  • Shortest is counted in crossings; time, distance and who rows are not weighed.
  • When there are many shortest solutions, the first twelve are listed and the rest are only counted.

Common mistakes

Forgetting that the boat needs a rower to come back
Every return trip needs someone who can row, which is why the farmer crosses so often.
Thinking the goat can never come back
Bringing the goat back is the key move in the traditional puzzle.

Privacy and your data

Puzzles run in your browser. With analytics consent, a count records how many crossings were made; your moves are not sent.