Subtract-a-square take 1, 4, 9, 16, …

A heap of tokens. On your turn, take away a square number of tokens from one heap. Whoever takes the last token wins. Golomb called it "remarkably complex" in 1966 and nobody has a formula yet. The losing heaps (cold positions) 0, 2, 5, 7, 10, 12, 15, 17, 20, 22, 34, … never differ by a square, so they are a square-difference-free set — the kind of set the Furstenberg–Sárközy theorem says has density 0. Yet they are about as dense as the best constructions number theorists know: roughly n0.7 of the first n numbers.

play against the solver (nim-values up to 20,000)

nim-values 0 … 4095 — 64 per row

Black = cold (nim-value 0). Click a cell to play that heap.

how many cold positions? — |C ∩ [0, n)| on log–log axes, n ≤ 230

largest nim-value — record values up to n = 224

low-order digits of the cold positions — all cold positions below 230

Bars are shares of each digit value; the dashed line is the uniform share. Highlighted digits form a square-difference-free set ({0,2} mod 5, {0,2,7} mod 13).

three algorithms — wall time in this repo's TypeScript (Node)

paper check