MathematicsPreprintTheory4 min read

THE LONGEST SNAKE THAT FITS IN 12 ROWS

Take a sheet of squared paper and shade a chain of squares, each touching the next along a side. Now add one rule: two squares that are not next to each other in the chain may touch at a corner, but never along a side. The chain can wind and turn, but it can never brush against itself. Mathematicians call such a shape a snake polyomino. Formally, the shaded squares form a single path: connected, without loops, and no square has three shaded neighbours.

The question is simple. In a rectangle m squares tall and n squares wide, how many squares can the longest snake cover? Call that number T(m, n).

A puzzle that only gets harder

For general networks, finding the longest path of this kind is computationally hard (NP-hard), so no general tool can answer it. For rectangles, an earlier result showed that T grows roughly like two thirds of the area, but that says nothing about exact values. A. Blondin Massé and A. Goupil found exact formulas for heights up to 5, conjectured that an explicit formula exists for every rectangle, and pushed complete enumeration as far as 15 by 15 squares.

For height 12, Goupil posted a conjectured formula in July 2026 in the On-Line Encyclopedia of Integer Sequences (OEIS), and another contributor, Howroyd, extended the data to 60 values by brute force. The formula has carried the word “Conjectured” ever since. As the new paper puts it, sixty terms cannot prove it: they cannot tell a genuine pattern from an artefact of the range they happen to cover.

44 squares every 6 columns

Tong Niu proves the conjecture. Write the width as n = 6k + r: k blocks of 6 columns plus r leftover columns, with r between 0 and 5. Then the longest snake in a grid 12 squares tall covers

T(12, n) = 44k + c, where c is 5, 12, 19, 27, 34 or 42 for r = 0, 1, 2, 3, 4 or 5,

for n = 1, n = 11 and every n from 13 onward. For a single column, that gives 12: the whole column, a straight snake. For n = 11, it gives 44 + 42 = 86. The ten widths in between are exceptions, listed one by one: 18, 26, 33, 40, 47, 55, 62, 70 and 77 for widths 2 to 10, and 92 for the 12 by 12 square, one fewer than the formula would give.

In the long run, that is 44 squares every 6 columns, about 7.33 squares per column. The value sits strictly between two easy bounds. Filling every other column completely and joining them with one square at each turn gives only 6.5 squares per column. A known upper bound for shapes where no square has more than two neighbours allows 8. Neither could settle the question, so a new argument was needed.

Two halves that must meet

The proof has two independent parts. For the upper bound, showing that no snake can be longer, a “transfer system” reads a snake one column at a time, keeping track of which squares of the current column are shaded and how they connect to what lies behind. For height 12, the useful part of this system has 173,994 states, the possible column patterns it tracks. Instead of checking the pattern forever, Niu shows that a single check is enough: going from 40 columns to 46 never adds more than 44 squares, whatever the state: the structure of the computation carries that inequality to all larger widths.

For the lower bound, showing that snakes this long exist, the paper simply draws the snakes: periodic families, one for each value of r, built from a fixed head, a repeated middle block and a fixed tail, plus 26 individual snakes for small widths. These are checked directly against the definition, without using the transfer system at all.

The two halves were designed to fail in opposite directions. An error in the transfer system could only make the upper bound too generous; an error in the drawn snakes could only make the lower bound too low. They meet exactly, “a check neither half could pass alone”.

Checked twice

The computation was run by two programs written independently, which agree on every count for heights 1 to 9 and on the core of the computation for heights 10 to 12. The machinery was tested on every snake of fifteen small rectangles, 42,287 snakes in all, and it reproduces the 60 published values for height 12 and all 10,000 published values for height 6. A self-contained script printed in the paper re-runs the part of the proof needed for height 12 in about 40 minutes on a laptop.

Every height up to 12

The same method settles every height from 1 to 12, and the patterns are anything but regular: the formulas repeat with periods of 1, 2, 1, 3, 7, 4, 6, 8, 4, 18, 8 and 6 columns. Height 11 only settles into its formula from width 52 onward. For heights 7 to 11, the OEIS had no entry at all, and these formulas appear to be the first. Height 13 should be within reach, the author notes, given a faster implementation. The square case, the longest snake in an n by n grid, remains a different and harder problem.