Seven stones lie in a row with the middle one empty. Three frogs stand on the left three stones facing right, and three toads stand on the right three stones facing left. Each animal may only move forward, either by sliding onto the empty stone in front of it or by jumping over one animal of the other kind onto the empty stone just beyond. Can the frogs and the toads swap sides, and what is the smallest number of moves that does it? This page counts what every solution must contain, which shows that any solution takes exactly 15 moves, and then gives a route that does it in 15.
Key terms
Frogs and toads puzzle
Definition The frogs and toads puzzle with animals of each kind, where , uses a row of stones numbered from left to right. At the start, frogs stand on stones to , toads stand on stones to , and stone is empty. Each stone holds at most one animal, so exactly one stone is empty at every moment. Frogs only ever move to the right and toads only to the left, one animal per move. A move is either a slide, in which an animal moves onto the empty stone directly in front of it, or a jump, in which an animal passes over the stone directly in front of it, which must hold an animal of the other kind, and lands on the empty stone just beyond. Nobody moves backward, jumps over an animal of its own kind or jumps over more than one stone. Any animal with a legal move may make it, so frogs and toads do not have to take turns. The goal is to have toads on stones to , frogs on stones to and stone empty again. The puzzle can be solved for every , and every solution contains exactly jumps and slides, so every solution has
moves. Some sequences of legal moves get stuck before reaching the goal, so a solution still has to be planned.
In plain words Frogs hop right, toads hop left, and nobody turns back. Every frog has to get past every toad, and the only way to get past is to jump. All solutions have the same length, but a careless move can leave every animal blocked.
Example Write F for a frog, T for a toad and for the empty stone. With one of each kind the row is . The frog slides, the toad jumps over it, and the frog slides again, which gives , then , then . That is moves. With two of each kind, the eight moves in the table solve the puzzle.
| Move | What happens | Stones 1 to 5 after the move |
|---|---|---|
| 1 | The frog on stone 2 slides to stone 3 | |
| 2 | The toad on stone 4 jumps to stone 2 | |
| 3 | The toad on stone 5 slides to stone 4 | |
| 4 | The frog on stone 3 jumps to stone 5 | |
| 5 | The frog on stone 1 jumps to stone 3 | |
| 6 | The toad on stone 2 slides to stone 1 | |
| 7 | The toad on stone 4 jumps to stone 2 | |
| 8 | The frog on stone 3 slides to stone 4 |
There are four jumps and four slides, and . If instead both frogs slide at the start, the row becomes and no animal can move, because the empty stone is behind both frogs and more than two stones ahead of each toad.
Counting argument
Definition A counting argument proves a fact about every solution of a puzzle at once by keeping count of some quantity. One chooses a quantity whose values at the start and at the goal are known and finds exactly how much each kind of move can change it. Every solution has to change the quantity by the full difference, which limits how many moves of each kind it can contain. The argument covers all solutions, including ones nobody has written down, but it does not show that a solution exists.
In plain words Instead of trying routes one after another, keep score of something that has to change between the start and the goal, and ask how much a single move can change it.
Example In the frogs and toads puzzle with of each kind, pair every frog with every toad, which gives pairs. At the start the frog of each pair is to the left of its toad, and at the goal it is to the right. A slide passes nobody, so it changes the order of no pair. A jump passes exactly one animal of the other kind, so it reverses the order of exactly one pair. A frog that has passed a toad can never fall behind it again, because frogs only move right and toads only move left. So each pair is reversed exactly once, and every solution has exactly jumps.
Now count distance. Frogs never pass one another, so the frog that starts on stone ends on stone , and the frogs travel stones in all. The toads travel the same distance to the left, so all the animals together travel stones. A slide covers one stone and a jump covers two, so a solution with slides satisfies
which gives . For three of each kind there are pairs, so jumps, and stones of travel. The jumps cover of them, which leaves slides and moves in total.
Lower bound
Definition A lower bound for a quantity is a number that the quantity is proved never to be less than. A lower bound for the number of moves in a puzzle means that every solution uses at least moves. It does not claim that a solution exists, and it does not claim that some solution uses exactly moves. A lower bound that the quantity actually reaches is called sharp.
In plain words A lower bound rules out doing better than some number. It does not promise that anyone can do that well.
Example For three of each kind, each count on its own gives a lower bound. The animals must travel stones and no move covers more than , so every solution has at least moves. Nine pairs must be reversed and no move reverses more than one, so every solution has at least moves. Both statements are true, but neither bound is sharp, because no solution has or moves. Combining the two counts gives the bound of , since the jumps cover only of the stones and the remaining stones need slides. That bound is sharp, as the route of moves below shows.
Minimum number of moves
Definition The minimum number of moves of a puzzle is the smallest number of moves among all its solutions. It exists only when the puzzle has at least one solution. Proving that the minimum is takes two facts, a lower bound showing that no solution uses fewer than moves, and a construction, which is a legal solution that uses exactly moves. For the frogs and toads puzzle with of each kind the minimum is . In this puzzle every solution has that length, so the minimum is also the only possible length.
In plain words A count can show how short a solution would have to be, but only an actual route shows that such a solution is there to be found.
Example For three of each kind, start from and let the two kinds move in runs, first the frogs, then the toads, and so on, with and moves in the runs. At every move of a run, the kind whose turn it is has exactly one legal move, so the runs fix the route.
| Run | Who moves | Moves | Stones 1 to 7 after the run |
|---|---|---|---|
| 1 | frogs | slide | |
| 2 | toads | jump, slide | |
| 3 | frogs | jump, jump, slide | |
| 4 | toads | jump, jump, jump | |
| 5 | frogs | slide, jump, jump | |
| 6 | toads | slide, jump | |
| 7 | frogs | slide |
The route has jumps and slides, so it meets the lower bound of , and is the minimum. In the middle of the route the empty stone sits at the far left with the animals alternating, and three toad jumps in a row carry it to the far right. The same pattern of runs, , then twice more, then down to , solves the puzzle for every . Its length is
Check yourself
- Four frogs and four toads stand on nine stones with the middle stone empty. How many jumps, slides and moves does a solution have, and do runs of and moves have the right total?
Show the answer
There are frog and toad pairs, so a solution has jumps. Each frog ends stones to the right of where it started, so the frogs travel stones, and the toads travel another to the left. The jumps cover of these stones, which leaves slides. A solution therefore has
moves, in agreement with and with . The runs add up to , as they should.
- Change the rules so that an animal may also move backward, by sliding back onto the empty stone directly behind it or by jumping back over one animal of the other kind. Jumping over an animal of the same kind is still forbidden. With three of each kind, is still the minimum, and does every solution still have moves?
Show the answer
The minimum is still , but solutions can now be longer. Count forward and backward moves separately, with and forward and backward jumps and and forward and backward slides. Call a pair finished when its frog is to the right of its toad. A forward jump finishes one pair and a backward jump undoes one, while slides change no pair, and the number of finished pairs goes from to . So . Measured in each animal’s forward direction, the animals still have to travel stones in net, so , which gives . The number of moves is then
Every solution therefore has at least moves, and the old route of moves is still legal, so is still the minimum. Backward moves only add to the count. For example, the frog on stone can slide forward to stone and straight back, and the old route then takes more moves, for in all. The counting argument still gives a sharp lower bound, but it no longer fixes the length of every solution.
- Extend the puzzle to unequal groups. Three frogs stand on stones to , stone is empty, and two toads stand on stones and . The goal is toads on stones and , stone empty and frogs on stones to . Count the jumps, slides and moves, find a route, and give the count for frogs and toads.
Show the answer
There are frog and toad pairs, so a solution has jumps. The frog that starts on stone ends on stone , so the frogs travel stones, and the toad that starts on stone ends on stone , so the toads travel stones. The jumps cover of the stones, which leaves slides and moves.
One route uses runs of and moves, starting with the frogs. The frog on stone slides. The toads jump and slide. The frogs jump, jump and slide, which gives . The toads jump twice, the frogs slide and jump, and a toad slides, which ends at after moves.
With frogs and toads there are jumps. The frogs travel stones and the toads , so the slides number . The number of moves is
which is for three frogs and two toads and when .