Solution (source code)

= Solution

For <Chomp>, one representation is a Boolean <array> `occupied(y)(x)` with one entry per cell. The initial board has every entry true. For the noninitial board in the figure, the sets of occupied column indices in successive rows $y=0,1,\ldots,5$ are $\{0,1,2,3,4,5\}$, $\{0,1,2,3\}$, $\{0,1,2,3\}$, $\{0,1\}$, $\varnothing$, $\varnothing$; all other entries are false.

A more compact representation is the <monotone boundary representation of a grid order ideal>: an <array> `row(y)` giving the number of occupied cells in row $y$. Occupied cells in a row always form a left prefix. The initial representation is $[6,6,6,6,6,6]$, and \b[the illustrated noninitial representation is $[6,4,4,2,0,0]$], indexed upwards from row zero. Its total is $16$. These descriptions use the same coordinate orientation as the original figure; no source image is needed in the solution.