# How Often Does a Random Nonogram Have Only One Answer? Methods and claim sheet

Publication date: 2026-11-18
Evidence label: reproducible calculation (exact enumeration, one seeded Monte Carlo estimate) with a
source-code inspection
Canonical page: https://www.altamens.com/research/nonogram-uniqueness/

## Question

If you fill the squares of a small grid at random, how often do the row and column clues of that
grid have exactly one solution, how often can that solution be reached one line at a time, and what
does that mean for the random generator of the Altamens Pixel Logic puzzle?

## Provenance

- No participant, customer, account, device, analytics or telemetry data was used. Nothing here
  measures how people solve puzzles.
- The generator modelled as `Pixel Logic p=0.55` mirrors `makePixels()` in
  `app/lib/puzzleCollection.ts` (last changed in commit `d8a87fd9809dcd0f1e8bc49ac32db382216d2867`,
  file SHA-256 `4c303ad689809f37a83b21a35f0f35bd96c23466fbb4575c0bcfb59a4ba49a79`, inspected
  2026-11-18): rounds 1 to 4 use a 4x4 grid and rounds 5 to 12 a 5x5 grid; each square is filled
  with probability 0.55; a grid is kept only if it has at least one filled and one empty square and
  `pixelSolutions()` finds exactly one solution for its clues; after 60 rejected attempts the
  generator returns a fixed striped grid. The game marks a board correct only when it equals the
  stored solution (`PixelBoard` in `app/components/CollectionGame.tsx`).
- `uniform p=0.50` (every grid equally likely) is included for comparison with published counts.

## Definitions

| Term | Meaning |
| --- | --- |
| Clues | For each row and column, the lengths of its runs of filled squares, in order (`0` for an empty line). |
| Unique | No other grid of the same size has the same row and column clues. |
| Line-solvable | Repeatedly taking one row or column at a time, listing every filling that fits its clue and the squares already decided, and fixing the squares on which all of them agree, decides every square. This is the "analyse each row and column in isolation" rule of OEIS A391619. |
| Accepted | Unique, with at least one filled and one empty square (the generator's rule). |

## Calculation

`calculate.py` enumerates every grid of size 3x3 (512), 4x4 (65,536) and 5x5 (33,554,432), encodes
its clues as one integer and counts how many grids share each clue set. A grid is unique when its
clue set occurs once. Probabilities under a fill rate p weight each grid with k filled squares by
p^k (1 - p)^(n*n - k), using exact fractions.

Line solvability is computed exactly for every unique 3x3 and 4x4 grid. For 5x5 it is estimated
from 200,000 accepted grids drawn at each fill rate with NumPy's `default_rng(20261118)`, with a
95% Wilson interval.

Derived quantities: the chance that 60 attempts all fail is (1 - a)^60, where a is the acceptance
probability per attempt; the expected number of attempts is (1 - (1 - a)^60) / a.

## Checks

1. The script asserts that its unique counts equal OEIS A242876 (384; 52,362; 25,309,575) and that
   its exact line-solvable counts equal OEIS A391619 (384; 51,234). Both pass.
2. The 5x5 Monte Carlo estimate for uniform grids, 98.69% (95% interval 98.64 to 98.73), contains the
   share implied by A391619 and A242876, 24,976,511 / 25,309,575 = 98.68%.
3. `check_generator.mjs` calls the site's own `pixelClues()`, `pixelSolutions()` and `makePixels()`
   with a seeded generator (mulberry32, seed 20261118). Observed acceptance: 85.46% of 20,000 4x4
   attempts (exact value 85.26%) and 83.17% of 20,000 5x5 attempts (exact 83.25%); 0 fallback grids
   in 5,000 calls.

## Claim sheet

| Claim in the paper | Source |
| --- | --- |
| 384 of 512 3x3, 52,362 of 65,536 4x4 and 25,309,575 of 33,554,432 5x5 grids are unique (75.0%, 79.9%, 75.4%) | `results.csv`, matches OEIS A242876 |
| 6x6: 49,745,060,669 of 68,719,476,736 grids unique (72.4%); 48,625,108,931 line-solvable | OEIS A242876 and A391619 (not recomputed here) |
| 4x4: 51,234 unique grids are line-solvable (97.85% of unique grids) | `results.csv`, matches OEIS A391619 |
| At p = 0.55, 85.26% of 4x4 and 83.25% of 5x5 attempts are accepted | `results.csv`, `p_accept_per_attempt_pct` |
| Expected attempts per board: 1.17 (4x4), 1.20 (5x5); chance of the fallback: about 1e-50 and 3e-47 | `results.csv` |
| Accepted boards are line-solvable 98.49% (4x4, exact) and 99.21% (5x5, 95% interval 99.17 to 99.25) | `results.csv` |
| A full 12-round game contains at least one board that is not line-solvable with probability about 11.7% | 1 - 0.9849^4 x 0.9921^8, from `results.csv` |
| 5x5 grids with 5 or 6 filled squares are unique about 28% of the time; with 16 or more, over 95% | `by_fill.csv` |
| Accepted boards have 56.8% (4x4) and 56.7% (5x5) filled squares on average | `results.csv`, `mean_fill_accepted_pct` |

## Reproduction

Python 3.11.18 with NumPy 2.1.3. About 1.5 minutes and 2 GB of memory on one core.

```text
python3 -m venv venv && venv/bin/pip install numpy==2.1.3
venv/bin/python calculate.py
```

Expected: no assertion error, and `results.csv` and `by_fill.csv` identical to the published files:

```text
26ec0fca8c06df71b6a00c0203f1565528411b3ab51cfa4c95b099e7265b6ed8  results.csv
e7387848cac3acb7ec97d79f71b68a71edde8ca1a6f5eee15a11b3fb7532d887  by_fill.csv
```

The generator cross-check needs Node.js 22.6 or later and a checkout of the Altamens repository.

## Limits

- Grid sizes 3x3 to 5x5 only; shares for larger grids come from the published counts.
- "Line-solvable" is one specific rule. People also use other shortcuts, and a puzzle that is not
  line-solvable can still be solved by logic; neither rule measures how hard a puzzle feels.
- The figures describe the generator as of the commit above. A change to the fill rate, the grid
  sizes or the uniqueness check changes them.
- AI-assisted. Automated checks only; no independent human methods review and no journal peer
  review. The OEIS counts are cited with attribution; OEIS content is published under CC BY-SA 4.0.
  No third-party data is redistributed.
