A circular racetrack has cans of fuel scattered round it, of different sizes and in no particular order, and between them they hold exactly enough for one lap. You may start beside any can you like with an empty tank, and you pour in each can as you pass it.
Show that there is always a can you can start from and finish the lap.
Number the cans in driving order. Can holds , and the leg from can to the next costs , with fuel measured in the distance it buys. Exactly a lap of fuel means
Drive the lap from can 1 and let the level go negative if it wants to. The level after leg is
and because the fuel is exactly a lap, as well.
This is the film's proof. Pick with as low as it gets, and start at can (can 1 if ).
Starting there, the level after each leg is the old level measured up from the bottom of the dip. Going on from to it is . Past can the track wraps round to can 1, and since the level is again. Each of those is at least zero, because is the lowest value. Nothing ever goes below empty, so the lap closes.
The same picture shows nothing else works. Start after any point that is not a lowest one and you meet the lowest point on the way round, where the level is .
Induction on the number of cans. With one can, and any start works.
With more, some can has , since otherwise the cans could not add up to a lap. You can leave that can and arrive at the next with fuel to spare. So pour the next can into it and delete that stop: one can now holds and the leg after it costs . There is still exactly a lap of fuel and one can fewer, so by induction some start works on the smaller track.
That same start works on the original. Starting at the merged can, you start at can , and you reach can with exactly the fuel the merged can promised. Starting anywhere else, you reach can with some level , and leaving it you have , so you arrive at can in the same state as on the smaller track.
Run backwards this is an algorithm. Drive from can 1 with an empty tank. The moment you get stuck, throw away everything so far and start again from the next can. One pass, nothing remembered except the current level.
Take whole numbers and suppose they add up to instead of . Let be the partial sums as before, so , and let be the last index in where is lowest. Start after .
Going on from to , every later is strictly above and the final one is . After the wrap the level is . So every partial sum is strictly positive.
Only the last lowest point works. Start after an earlier tie and you reach that later one with level . Start after anything higher and you reach a lower point with level or less. So exactly one of the rotations has every partial sum above zero. This is the cycle lemma, usually credited to Dvoretzky and Motzkin (1947) and to Raney (1960). It holds for any whole-number steps, not just the of the next section.
The film's track has 5 cans holding 5, 9, 2, 10, 4 and legs costing 8, 3, 6, 4, 9. Both add up to 30, one lap. Driving from can 1 on the imaginary tank gives levels −3, 3, −1, 5, 0, so the lowest is −3, after leg 1, and the start is can 2.
| Start at | Fuel left after each leg | Result |
|---|---|---|
| can 1 | −3 | runs dry on leg 1, 3 short |
| can 2 | 6, 2, 8, 3, 0 | gets round |
| can 3 | −4 | runs dry on leg 1, 4 short |
| can 4 | 6, 1, −2 | runs dry on leg 3, 2 short |
| can 5 | −5 | runs dry on leg 1, 5 short |
Exactly 1 of the five starts works, which is the point of choosing this track. It looks like luck until the proof lands.
Start at can 1 and the curve dips below the axis, and where it dips lowest is just before can 2. Start at can 2 and the whole curve lifts above the axis. Nothing about it has changed except where zero is.
More than one start can work. When the level touches its lowest value more than once, every touch gives a start. The film's three other tracks, solved by the same rule:
| Cans | Legs | Starts that work |
|---|---|---|
| 7, 17, 11, 3, 11 | 6, 14, 22, 3, 4 | 4 and 5 |
| 5, 22, 1, 5 | 18, 8, 3, 4 | 2 |
| 8, 7, 22, 4 | 4, 19, 15, 3 | 3 |
Change any can or leg, roll a random track, or shuffle the cans: every start is driven out on the spot.
| Start at | Fuel in the can | Next leg costs | From here |
|---|---|---|---|
| can 1 | 5 | 6 | dry on leg 1→2 |
| can 2 | 6 | 0 | dry on leg 5→6 |
| can 3 | 3 | 5 | dry on leg 3→4 |
| can 4 | 9 | 9 | dry on leg 5→6 |
| can 5 | 4 | 9 | dry on leg 5→6 |
| can 6 | 4 | 2 | finishes the lap |
Too little or too much fuel. If the cans hold less than a lap, no start can work, whatever the order, because the level at the end of the lap is negative from any start. If they hold more, take the surplus out of any one can and the track has exactly a lap, so a start exists, and it still works with the surplus put back. The table below counts every case:
| Cans | Less: tracks | …with a start | Exact: tracks | …with a start | More: tracks | …with a start |
|---|---|---|---|---|---|---|
| 1 | 6 | 0 | 4 | 4 | 6 | 6 |
| 2 | 106 | 0 | 44 | 44 | 106 | 106 |
| 3 | 1,758 | 0 | 580 | 580 | 1,758 | 1,758 |
| 4 | 28,722 | 0 | 8,092 | 8,092 | 28,722 | 28,722 |
| 5 | 466,136 | 0 | 116,304 | 116,304 | 466,136 | 466,136 |
How many starts can there be? One, as on the film's track, and up to all of them. If every can matches its leg ( everywhere), every start works. With five cans holding 1, 0, 0, 0, 0 and legs costing 0, 1, 0, 0, 0, exactly the cans 1, 3, 4, 5 work, which is every one but can 2. The number that work is the number of times the level touches its minimum, nothing else. For every track of up to 5 cans with cans and legs from 0 to 3, the starts that work are exactly the cans after a lowest point.
Not only integers. Proofs one and two only compare levels, so they never use whole numbers. Whole numbers are what the script can enumerate, and what proof three needs for "strictly positive" to mean "at least one unit".
Now take the stations away. A road of length goes round a circle. Fuel is supplied along it at a density and burned at a density , both per kilometre, and the net rate is . Exactly enough fuel for a lap means
Measure the road in laps, so ; nothing else changes. Let
be the level on arriving at if you had started at on the imaginary tank. Because , , so lives on the circle. Start at with an empty tank and the level at , for from round to , is
The first half is one line: everywhere says everywhere. The second half is where continuity does the work that checking finitely many cans did. is continuous and periodic, so it is a continuous function on a circle, which is closed and bounded, and the extreme value theorem says it attains its minimum. Start at a point where it does, and the whole way round.
Take with and . It averages to zero, and has a closed form, so there is an exact answer to compare with. changes sign twice. It goes from to at , where is highest (0.2660). It goes from to at : bisection gives 0.820000000000, to machine precision, and . So is a minimum, and it is the global one, . The only start that works is .
The right panel is the same curve with the start moved to : the whole of it lifts onto the axis, touching it only at the two ends. That is the film's picture with the stations taken out.
A flatter bottom is possible. With instead, has a triple zero at , so vanishes there as well and grows like : doubling the distance from multiplies the rise by 16.0. The minimiser is still unique and still , but the bottom is very flat.
The film's problem is this one with a particular . A can is fuel poured in all at once, which is a point mass of size at its position, and a leg is a steady burn. Fuel in the film is measured in the distance it buys, so the burn is per unit distance, , and the lap is with the cans at positions 0, 8, 11, 17, 21:
| Can | Position x | Fuel poured in there | Level Φ on arriving |
|---|---|---|---|
| 1 | 0 | 5 | 0 |
| 2 | 8 | 9 | −3 |
| 3 | 11 | 2 | 3 |
| 4 | 17 | 10 | −1 |
| 5 | 21 | 4 | 5 |
Between cans falls with slope . At a can it jumps up by the fuel there. So its lowest values are the levels on arriving at a can, just before the jump: here −3 at , which is can 2. "Start just after the lowest point" and "start at the can where the arrival level is lowest" are the same instruction.
One technical point is worth saying once. At a jump, has to be defined by the level on arriving, which counts only the cans strictly before . That version is lower semi-continuous, meaning it never sits above its own limits from either side, because every jump goes up: cans only add fuel. That is exactly what the extreme value argument needs, so the minimum is still attained. If fuel could also be removed in an instant, a jump down would let get lower and lower without ever reaching its infimum, and there would be no best start. So the density may burn, and the point masses may only supply.
The starts that work are the minimisers of , and since is lower semi-continuous that set is closed and not empty. Beyond that, anything goes:
Rotate the circle to start at a minimiser and write for . Then and : a continuous bridge turned into an excursion. This is the continuous cycle lemma. Vervaat (1979) applied it to a Brownian bridge, whose minimum is almost surely unique, and showed that the rotated path is a Brownian excursion. That is a pointer only; everything above is the deterministic half.
Cut the example road into equal cells and make each a legitimate station problem. Cell contributes its net fuel , as a can of with station at and a leg costing . That is the one honest choice: each cell's net is exact, and what is lost is only what happens inside it. The level on arriving at station is then exactly , so the starts that work are the grid points where is lowest.
falls from its maximum to and rises again, with no other turning point (checked below), so the lowest grid point has to be one of the two beside . That puts it less than away, and the table shows how much less. Both statements lean on there being a single dip: with two dips of nearly the same depth, a coarse grid can pick the wrong one.
| Stations n | Start that works | Position j/n | Distance to the minimiser | Distance × n | Starts that work |
|---|---|---|---|---|---|
| 8 | can 8 | 0.875000 | 0.055000 | 0.440 | 1 |
| 16 | can 14 | 0.812500 | 0.007500 | 0.120 | 1 |
| 64 | can 53 | 0.812500 | 0.007500 | 0.480 | 1 |
| 256 | can 211 | 0.820313 | 0.000312 | 0.080 | 1 |
| 1024 | can 841 | 0.820313 | 0.000312 | 0.320 | 1 |
At eight stations the winner is the eighth, at 0.875, 0.055 from . With a thousand and twenty-four stations it is 0.000312 away. Exactly one start works at every size.
Add a constant surplus: with . A start works exactly when
with continued periodically. For the point breaks this at once, so no start works. For it is the minimisers. For every start that worked at still works, because the surplus only raises , so the set of good starts can only grow as does. Near a minimum with it grows into an interval about long: start after and the tightest point is just before you come round to again, where the surplus has put you ahead, so you need roughly .
| Surplus δ | Starts from | to | Length | Length ÷ √(2δ/κ) |
|---|---|---|---|---|
| 0.0001 | 0.8199 | 0.8289 | 0.0089 | 1.00 |
| 0.001 | 0.8196 | 0.8477 | 0.0281 | 1.00 |
| 0.01 | 0.8160 | 0.9023 | 0.0863 | 0.97 |
| 0.05 | 0.8003 | 0.9826 | 0.1824 | 0.91 |
Give every can the value or : a can holding one unit with no leg, or a leg costing one unit with no can. Take of the first kind and of the second. That is steps adding up to , and the cycle lemma says that among the rotations of any such sequence exactly one stays positive throughout. So the fraction of sequences that already do is , and the count is
which is the Catalan number, the same one that counts balanced bracket strings of pairs.
| m | Steps | Sequences with total +1 | …always positive from the start | Sequences ÷ steps |
|---|---|---|---|---|
| 1 | 3 | 3 | 1 | 3 / 3 = 1 |
| 2 | 5 | 10 | 2 | 10 / 5 = 2 |
| 3 | 7 | 35 | 5 | 35 / 7 = 5 |
| 4 | 9 | 126 | 14 | 126 / 9 = 14 |
| 5 | 11 | 462 | 42 | 462 / 11 = 42 |
| 6 | 13 | 1716 | 132 | 1716 / 13 = 132 |
| 7 | 15 | 6435 | 429 | 6435 / 15 = 429 |
| 8 | 17 | 24,310 | 1430 | 24310 / 17 = 1430 |
An election is the same thing. Candidate A gets votes and B gets with . Counting the votes one at a time, how often is A strictly ahead throughout? The total is , and the same argument gives exactly good rotations out of , so the fraction is
This is Bertrand's ballot theorem.
| Final count | Orders the votes can come in | A ahead throughout | Fraction | Good rotations of each order |
|---|---|---|---|---|
| 2 to 1 | 3 | 1 | 1/3 | 1 |
| 3 to 1 | 4 | 2 | 1/2 | 2 |
| 3 to 2 | 10 | 2 | 1/5 | 1 |
| 4 to 2 | 15 | 5 | 1/3 | 2 |
| 5 to 3 | 56 | 14 | 1/4 | 2 |
| 6 to 2 | 28 | 14 | 1/2 | 4 |
| 7 to 4 | 330 | 90 | 3/11 | 3 |
| 8 to 3 | 165 | 75 | 5/11 | 5 |
None of the above is left to the proofs. scripts/fuel.mjs reads the film's own track.json, re-derives every level and every working start in it, and asserts that they agree. Then it checks the rest, and the continuous section as well.
Every small track. Every can holds 0 to 3 and every leg costs 0 to 3, for up to 5 cans. That is 1,118,480 tracks, of which 125,024 hold exactly a lap. Every one of those has a start that works, and the working starts are exactly the cans after a lowest point.
| Cans | Tracks | 1 start | 2 starts | 3 starts | 4 starts | 5 starts | None |
|---|---|---|---|---|---|---|---|
| 1 | 4 | 4 | — | — | — | — | 0 |
| 2 | 44 | 28 | 16 | — | — | — | 0 |
| 3 | 580 | 348 | 168 | 64 | — | — | 0 |
| 4 | 8,092 | 4,692 | 2,248 | 896 | 256 | — | 0 |
| 5 | 116,304 | 66,020 | 31,580 | 13,200 | 4,480 | 1,024 | 0 |
Random tracks. Three ways of finding a start are run on random tracks: start after the lowest point, drive until stuck and restart, and shrink the track. Each returns a start that finishes. On tracks of up to 1000 cans, the full list of working starts, found by trying every one, is compared with the cans after the lowest points. On 20 tracks of 100,000 cans the linear methods are checked by driving the lap.
| Cans | Tracks | Starts that work, on average | Most seen |
|---|---|---|---|
| 5 | 5,000 | 1.05 | 3 |
| 50 | 2,000 | 1.07 | 4 |
| 1000 | 100 | 1.03 | 2 |
| 100,000 | 20 | — | — |
The continuous example. is checked against numerical integration of , its two sign changes are found by bisection, is checked at the minimum, and the global minimum is confirmed on a grid of 2,000,000 points and refined to many digits, with exactly 2 turning points. The film's track, read as a road, gives the same arrival levels as the film. Every discretisation above is built as a real station problem and solved by the same code as the rest, and its working starts are compared with the cans after the lowest level. The surplus intervals are found on a grid of 40,000 points with a sliding minimum.
The lab. The track lab above runs the functions in site/lib/fuel-core.mjs, the same text the script imports, so a green start on the page is a start the script asserted. On 30,000 random tracks of 3 to 12 cans with whole units from 0 to 9, its drive agrees with the lap check from every start, the working starts are exactly the cans after the lowest level on all 15,000 tracks with one lap of fuel, there is always at least one of them, and none works with less than a lap.
The cycle lemma. For whole-number steps between and , up to seven of them, there are 70,553 sequences with total , and every one has exactly one good rotation. For steps the tables above count every sequence.
No. From any start, the level at the end of the lap is the total fuel minus the total cost, which is below zero, so you are stuck somewhere on the way round. In the table of tracks above, none of those with less than a lap has a start that works. So "exactly enough" is doing real work.
Both, for every from 2 to 12. If every can equals its leg, every start works. For , put one unit in can 1 and a leg costing one unit after can 2, and nothing anywhere else. The cans 1, 3, 4, 5 work for five cans, and can 2, where you are stuck at once, is the one that fails.
Exactly one. That is the cycle lemma, proof three. Among the rotations of any sequence with total , exactly one is positive throughout, and counting those sequences gives the Catalan numbers in the table above.
Yes. Drive from can 1 keeping only the current level. When it goes negative, drop it back to zero and start again from the next can. At the end, if the total fuel is at least a lap, the last can you restarted from is a start that works. That is proof two as an algorithm. It uses nothing but the current level, so it works the same for 100,000 cans as for five.
At , which is the same point as . Here , which is never negative. Its minimum is 0, at , and that is where goes from negative to positive. It is the only start that works. The opposite point is the worst one: is highest at , where goes from positive to negative, with value 0.3183, and starting there you finish −0.3183 below empty. A minimum is where changes sign from to ; the other sign change is a maximum.