A bar of chocolate is 6 squares tall and 8 wide. The square in the bottom-left corner is poisoned.
Two players take turns. On your turn you pick one square and bite: you eat that square and every square above it and to its right. Whoever has to eat the poisoned square loses.
Who wins with perfect play, the player who goes first or the player who goes second?
The poison is the navy square with the skull. Rows are counted from the bottom and columns from the left, so the poison is row 1, column 1.
A bite takes everything above and to the right of the square you pick, so what is left always gets shorter as it goes up, never longer. We call what is left a position, and we write it as the length of each row from the bottom up. The full bar is 8, 8, 8, 8, 8, 8. After the bite above, the position is 8, 8, 5, 5, 5, 5.
There are two proofs below. The first is a search a computer can do for any bar of reasonable size. The second is a short argument that covers every bar at once, and it never finds the winning bite. Both start from one idea.
A position is winning if the player about to move can force a win, whatever the other player does. It is losing if the other player can force a win instead. Here is why every position is exactly one of the two, working backwards from the end of the game.
Every position gets one label, and the labels mean what they say. From a winning position, move to a losing one. Your opponent can only answer by moving to a winning one, and you move to a losing one again. Each move eats a square, so this ends, and you never eat the poison, because the empty position is winning, not losing. So the other player does. Nobody can force a draw.
Here are the four smallest positions with a poison in them, labelled this way:
This is the fact the steal needs: the full bar is either winning or losing for the first player, and if it is losing, the second player wins.
Now do the same for every position of a 3 × 3 bar. The positions are grouped by how many squares are left, and coloured in that order, fewest squares first.
The empty position is the twentieth, and it counts as winning. Of the other 19, 5 are losing: 1; 2,1; 2,2,1; 3,1,1; 3,2. Every other position has a bite that leads to one of those five. The full 3 × 3 bar is winning, and its winning bite leaves 3, 1, 1.
Click a square to bite. The page tells you whether the position you leave is winning or losing for whoever moves next. You move first against a computer that knows the whole table. Show the winning bites if you want to see where they are.
| Bar | Winning first bite | Leaves |
|---|---|---|
| 2 × 3 | row 2, column 3 | 3, 2 |
| 3 × 3 | row 2, column 2 | 3, 1, 1 |
| 4 × 5 | row 3, column 3 | 5, 5, 2, 2 |
| 5 × 5 | row 2, column 2 | 5, 1, 1, 1, 1 |
| 6 × 8 | row 3, column 4 | 8, 8, 3, 3, 3, 3 |
The backwards labelling above is a program. Label the positions with one square, then with two, and so on up to the full bar. The film does this for a 2 × 3 bar, which has 10 positions. The verifier does it for every bar up to 9 × 9 and finds that the first player wins every one except 1 × 1.
How many positions? Follow the outline of a position from the top-left corner to the bottom-right. It is steps down and steps right in some order, and every order is a different position, so an bar has
of them. Every one can be reached by biting, working from the top row down. A 3 × 3 bar has 20, a 5 × 5 bar 252, and the 6 × 8 bar 3003, of which 142 are losing. A computer settles that in an instant.
A 100 × 100 bar has positions. That is a number with 59 digits, about . No computer will ever search that.
So the search settles the bars on its list and says nothing about any other bar. It also gives only a table, never a rule. The second proof covers every bar.
The idea is to suppose the second player wins, and to show that the first player could have copied his strategy. That is a contradiction, so the second player cannot win.
Take any rectangular bar with at least two squares, and suppose the second player wins. Then is a losing position for the first player. The pictures use the 4 × 5 bar. There the second player really does have a winning reply, which is what makes the theft work.
So is winning for the first player. On the 1 × 1 bar, step 1 fails: the top-right square is the poison.
On the 4 × 5 bar the second player's reply to the corner bite is the bite at row 3, column 3. It eats 5 squares after the corner has gone, and 6 on the full bar. Either way what is left is 5, 5, 2, 2, a loss for the player to move.
Why the corner is the whole trick. The steal works because every bite contains T. If a bite could leave T standing, then on the full bar would leave one square more than "T, then ", and nothing would follow. That is why this is about rectangles. A staircase with several outer corners has no square that every bite must take.
The first proof is a table, and the second only says that a winning bite exists. Neither gives a rule for a bar nobody has tabulated. The steal even avoids naming : it says a winning reply to the corner bite could have been played first, and if there is no such reply, the corner bite itself wins.
For two kinds of bar there is a rule, and it is short. For three rows nobody has one.
Nothing later depends on this section.
On an bar with , bite the square diagonally next to the poison, at row 2, column 2. That leaves an L: the poison, with squares up the left edge and along the bottom. For a 4 × 4 bar that is 4, 1, 1, 1, and for a 5 × 5 bar 5, 1, 1, 1, 1.
An L with two arms of the same length is losing for the player to move. Whatever he bites, one arm gets shorter (or he eats the poison and loses at once). Cut the other arm to the same length, and the L is equal again and shorter. Repeat, and the arms run out first for him. Formally this is induction on the arm length : for only the poison is left, and every move from an equal L has an answer that leaves a smaller equal L.
So the first player wins every square bar by leaving the L and then mirroring. The verifier finds that for every square up to 9 × 9 this is the only winning first bite.
On a 2 × bar, bite the top-right square. The bottom row has squares and the top row . Write for the position with a bottom row of squares and a top row of . The film's 2 × 3 and 2 × 5 bars leave 3, 2 and 5, 4.
is losing for the player to move, for every . Induct on . is the poison alone. For , take any move that is not the poison:
Either way the answer leaves a smaller , so every move from is answered. The verifier finds that the corner bite leaves n, n-1 as a losing position for every up to 30, and that it is the only winning bite up to .
Here are the winning first bites for , found by the search:
Each is the only winning bite on its bar. The even shown, and , leave two equal short rows, and the odd from 5 do not. This is a table up to , not a theorem about all . The film says no formula is known, and this page does not claim there is none.
The steal works on rectangles. A position that is not a rectangle can be losing for the player to move. The 3 × 3 map has several, and 3, 1, 1 is one. The theorem also holds for and together, since they are the same game turned on its side, and the verifier checks that the two orientations agree.
The film plays a 4 × 6 bar for 7 moves. The first player always bites something that does not win, and the other player always finds the winning reply. Near the end the position is 1, 1, the poison and the square above it. The second player takes the square above, and the first player is left with the poison alone.
The bite at the top of this page is the first of the film's three demonstration bites on the 6 × 8 bar, at row 3, column 6; row 5, column 4; and row 2, column 7. It eats a block 4 squares tall and 3 wide, 12 squares in one piece.
scripts/chomp.mjs writes the numbers on this page and asserts them first.
Every bar up to 9 × 9. It solves all 81 bars by search and asserts that the first player wins every one except 1 × 1. It counts the positions reached from each bar and asserts the count is exactly .
The winning bites. The bites quoted for 2 × 3, 2 × 5, 3 × 3, 4 × 4, 5 × 5 and 3 × 5 are exactly the winning bites found. For squares and for 2 × up to the winning bite is unique. The corner bite leaves the lost position for 2 × up to , and the equal L is lost for every square up to 9 × 9.
The steal, step by step. For every bar bigger than 1 × 1 up to 9 × 9, and every possible reply to the corner bite, 1944 in all, the script asserts that is a legal bite on the full bar, that its rectangle contains the corner, and that on the full bar gives exactly the position "corner, then ". It also checks the conclusion on each bar.
The playable bar and the diagrams. The page draws every diagram, and plays the game above, with one piece of code, site/lib/chomp-core.mjs. The script checks that code against its own solver on all 48,620 positions of the 9 × 9 bar: who wins, every move, every bite, and the computer's reply. It checks that the copy pasted into this page is the same. Each diagram is built in the script from those positions. For each one, the squares drawn as eaten are exactly what the bite eats, the colour is the solver's, and the number of squares drawn is the right number. A wrong diagram stops the build.
What is not checked. The proofs on this page are for every bar. The script tests bars up to 9 × 9, and goes further for the 2 × corner. That Chomp has been studied since 1974, and that no efficient algorithm for general bars is known, are claims about the literature, and the script does not assert them.
The corner is the poison. The first step, bite only the top-right square, is eating the poison, which loses at once. And the conclusion is false: the first player has one move, and it loses.
Bite the long arm down to length 2. That leaves an equal L, which is losing for the player who must move.
, and the verifier's count is 20. The same formula gives for the 2 × 3 bar, the 10 positions of the film's tree.
The top-right square. That leaves 2, 1, the last of the four small positions above, which is losing. If the second player bites the square above the poison, the bottom row of two is left, and the answer is to bite its right-hand square, which leaves the poison alone. If he bites the right-hand square instead, the poison and the square above it are left, and the answer is to take that square. Either way the second player is left with the poison.