Four people stand at one end of a rope bridge at night. Alone, they take 1, 2, 5, 10 minutes to cross. The bridge holds at most two at a time. There is one torch, and nobody may cross without it, so someone must carry it back for the next crossing. Two people crossing together go at the pace of the slower one. What is the least total time for all four to get across?
Write the four times , which for the film are 1, 2, 5, 10. A move is one crossing: one person or two, going over with the torch or coming back with it. A move costs the time of its slowest walker, and the clock is the sum.
The natural plan is to let the fastest walker, 1, take everybody over, one at a time, and walk the torch back each time:
| move | who | cost | clock |
|---|---|---|---|
| over | 1, 2 | 2 | 2 |
| back | 1 | 1 | 3 |
| over | 1, 5 | 5 | 8 |
| back | 1 | 1 | 9 |
| over | 1, 10 | 10 | 19 |
That is 19 minutes. It is the plan most people find first. The film also tries others, of 21, 25 and 23 minutes, which are all slower. In the escort plan the 5 and the 10 cross in separate moves, so they cost 15 minutes between them, out of the 19.
The script checks that 19 is the best possible for any plan in which the 5 and the 10 never cross together. It does so by searching every plan of that kind.
The 5 and the 10 are the expensive ones. Crossing together costs 10, the pace of the slower, not . The pair rides for the price of one. But the torch then has to come back, and neither of them should carry it, since walking back costs at least 5. So a fast walker must already be on the far side. That is why the first move sends the two fast walkers over:
| move | who | cost | clock |
|---|---|---|---|
| over | 1, 2 | 2 | 2 |
| back | 1 | 1 | 3 |
| over | 5, 10 | 10 | 13 |
| back | 2 | 2 | 15 |
| over | 1, 2 | 2 | 17 |
That is 17 minutes. The other plan of the same length has the 2 walking back first and the 1 later:
| move | who | cost | clock |
|---|---|---|---|
| over | 1, 2 | 2 | 2 |
| back | 2 | 2 | 4 |
| over | 5, 10 | 10 | 14 |
| back | 1 | 1 | 15 |
| over | 1, 2 | 2 | 17 |
Split each plan into the time spent going over and the time spent coming back.
| plan | going over | coming back | total |
|---|---|---|---|
| escort | 17 | 2 | 19 |
| pair | 14 | 3 | 17 |
The pairing plan spends more on coming back, 3 against 2, because the 2 walks back instead of the 1. It saves more on the way over, 14 against 17, because the 5 crosses for free. The saving is larger than the cost, and the difference is 19 − 17 = 2 minutes.
In letters, the escort plan costs and the pairing plan costs . The difference is
For the film that is . Pairing is better exactly when this is positive, which is .
A hand proof has to rule out every strange plan, such as three people on the far side and one coming back and forth. The script does that by brute force. It lists every reachable position, that is who is on which bank and where the torch is, finds that there are 30 of them, and then follows every route that never repeats a position. There are 73,644 such routes, and the cheapest costs 17. No route costs 18 and none costs 22. That is a proof by exhaustion, and it settles the film's four times.
What the brute force does not do is say why. The reason is in the two plans. The ordinary moves are needed whatever happens: at least three crossings carry someone over and at least two bring the torch back. The only decision is whether the two slowest walkers share a crossing. If they do, only one of them is paid for, and the torch must be fetched by a fast walker. If they do not, both are paid for. The rule above weighs the two.
The film's times are special. Change them and the better plan changes.
| times | escort | pair | best | better plan |
|---|---|---|---|---|
| 1, 2, 5, 10 | 19 | 17 | 17 | pair |
| 1, 2, 3, 4 | 11 | 11 | 11 | tie |
| 1, 5, 5, 10 | 22 | 26 | 22 | escort |
| 1, 2, 3, 10 | 17 | 17 | 17 | tie |
With 1, 5, 5, 10 the escort plan wins, because the second walker is slow too: in the pairing plan the 5 has to walk the torch back, and that costs more than it saves. The rule against says exactly this: here against . For the other three rows, against is against , against and against , which gives a pairing win and two ties.
The script checks the formula over every sorted set of four times from 1 to 12, which is 1365 sets, by comparing it with a shortest-path search (Dijkstra's algorithm) over the positions. The two agree in every case: the pairing plan is strictly best in 581, the two tie in 203 and the escort plan is strictly best in 581.
scripts/bridge.mjs asserts the claims below before it writes maths.json, and its --check fails if the file is stale. It checks that:
Escort: . Pairing: . So the escort plan wins here, and the best is 18. The rule agrees: is more than .
The 5 and the 10 cross together, and the torch must then come back. Whoever carries it back pays their own time again, so it should be a fast walker, and a fast walker has to be on the far side already. Sending the 1 and the 2 first puts one there.
It saves more going over. With the 5 and the 10 together, the three trips over cost 14 instead of 17, a saving of 3, and the extra return costs 1. A saving of 3 for a cost of 1 is a net of 2.