DEV Community

SEN LLC
SEN LLC

Posted on

Magnets: a clue that can't see half the board, and a generator that cannot dead-end

Magnets in the browser with five rule sets inside. The board is
pre-tiled into dominoes; each domino either becomes a magnet — a +
pole on one half, a pole on the other — or stays neutral. Two
cells sharing an edge may never hold the same pole, and the margins count
every row and column's + cells and cells. Puzzle #45 in the solver
series.

Demo: https://sen.ltd/portfolio/magnets/
Repo: https://github.com/sen-ltd/magnets

Magnets

The difference clue is blind to half the board

Each line (row or column) carries two numbers: its + count and its
count. The useful way to read them is as a sum and a difference.

The sum counts magnetised cells and cannot tell + from . The
difference can — but it cannot see any domino lying inside the line.
A domino tucked horizontally into a row contributes one + and one if
it is a magnet, and nothing if it is neutral; either way it cancels out of
the difference. What survives is exactly the cells whose domino crosses
the line, one half in, one half out:

plusClue − minusClue = Σ over crossing cells of σ,   σ ∈ {+1, −1, 0}
Enter fullscreen mode Exit fullscreen mode

The difference clue is a signed flux through the line's boundary, and
the in-line dominoes drop out of that integral identically. A Kakuro sum
talks about every cell in its scope; a Magnets difference is structurally
unable to mention half of its own line.

The solver's third rung, flux, reasons from that identity alone: interval
bounds on the sum of σ terms, plus one parity fact — when every other
crossing cell is known magnetised, the remainder's parity is forced.

Turn the tiling sideways and the same 32 numbers say nothing

The identity has a measurable consequence. Give the tiling generator a
horizontal bias hbias and sweep it, keeping the clue count fixed at 32
numbers per 8×8 board:

hbias crossing cells per row rows with difference 0 pinned by flux pinned by probe exactly one answer
0.00 (all vertical) 8.00 28.4% 1.6% 3.8% 0.0%
0.25 6.16 33.0% 10.8% 71.7% 23.8%
0.50 4.51 39.8% 20.4% 87.3% 50.0%
0.75 2.74 46.6% 15.7% 80.1% 35.0%
1.00 (all horizontal) 0.00 100.0% 2.7% 7.7% 0.0%

At hbias = 1 every domino lies inside its row, so every row's
difference clue is identically zero
— it carries no bits at all. The
information moves wholesale into the columns… and the puzzle dies anyway:
uniqueness collapses from 50% in the isotropic middle to 0% at both ends.

The culprit is the certificate below. Parallel dominoes stacked on the same
two tracks are precisely the configuration that can trade states silently,
and an anisotropic tiling mass-produces it. An isotropic tiling keeps both
readings of the clue pair alive; an anisotropic one kills one reading and
paves the board with silent pairs.

A generator that cannot dead-end — as a theorem

Every generator in this series has claimed "no search, no rejection", but
always as a measurement. Magnets is stronger: the filling phase provably
cannot fail
.

Drawing an answer takes two steps. The tiling is laid scan-order with a
bounded restart. The filling then visits dominoes in random order and gives
each a state that is legal right now — and since a neutral domino
conflicts with nothing
, the set of legal states is never empty. Neutral
is a structural escape hatch:

// Both magnet orientations may be blocked by neighbours — neutral never is.
if (legalPole(a, PLUS) && legalPole(b, MINUS)) options.push([PLUS, MINUS]);
if (legalPole(a, MINUS) && legalPole(b, PLUS)) options.push([MINUS, PLUS]);
// options may be empty; grid[a] = grid[b] = NEUTRAL always advances.
Enter fullscreen mode Exit fullscreen mode

The price of the guarantee is a density dial, and both of its ends are
easy:

8×8, magnetise mean magnetisation count finishes probe finishes exactly one answer
0.0 0.0% 100.0% 100.0% 100.0%
0.4 36.6% 8.3% 41.7% 41.7%
0.8 65.7% 0.0% 56.7% 56.7%
1.0 75.7% 0.0% 50.0% 50.0%

An all-neutral board is trivially unique (every clue is 0); a packed board
is rigid again because adjacency dictates. Ambiguity lives in the middle,
at the density where the adjacency rule has started to bite but not yet to
rule.

Two incomparable rungs under one roof

The ladder is five levels: pole (raw bookkeeping — domino coupling plus
"a pinned pole erases its neighbours"), then count (each clue as a
per-sign census over all cells of the line) and flux (the signed sum over
crossing cells only), then gac, then probe.

count and flux are incomparable — the census sees every cell but
cannot mix signs; the flux mixes signs but sees only the crossing cells.
Neither subsumes the other. But every constraint of this puzzle lives
inside some line: horizontal adjacency in the row, vertical adjacency in
the column, and each domino's coupling in whichever line the domino lies
in. So gac — exact enumeration of one line at a time — is a roof over
both middle rungs, and over pole too. That is a theorem that predicts the
ablation table, and the measurement agreed bit for bit:

10×10 finished cells pinned fixpoints that moved line assignments built probes
full 40.0% 80.5% 3,424 215
−pole 40.0% 80.5% 0 of 20 6,071 215
−count 40.0% 80.5% 0 of 20 3,491 215
−flux 40.0% 80.5% 0 of 20 3,548 215
−gac 25.0% 58.6% 8 of 20 0 476
−probe 25.0% 40.9% 15 of 20 327 0

Remove any of the three cheap rules and the fixpoint does not move by a
single bit, on any board, at any size (6×6 and 8×8 show the same zeros).
What moves is the bill: dropping pole nearly doubles the roof's
enumeration work. The middle rungs' preconditioning discount is small
(2.8–9.6%); the biggest accelerator was the cheapest bookkeeping. Only the
roof and the probe change what gets solved.

One more zero worth printing: pole alone finishes 0.0% of boards at
every size. With no domino revealed, coupling and adjacency have no
purchase — 100% of this puzzle's information is in the margins.

The √2 census

Soundness is pinned by an independent engine that shares no machinery with
the ladder: it deals each domino its three states in scan order, with only
raw bookkeeping, and scores every leaf against the rule text. The two
engines agreed on 462/462 solution counts across mixed clue regimes.

But engine-vs-engine agreement can miss a shared misunderstanding, so the
raw engine also gets checked against something outside the repo. On a
clue-free 1×2k strip, the number of legal fillings obeys the transfer
matrix over {neutral, +−, −+}, giving a(k) = 2a(k−1) + a(k−2) — OEIS
A001333, the numerators of the continued-fraction convergents of √2:

k 1 2 3 4 5 6 7 8 9
engine 3 7 17 41 99 239 577 1,393 3,363

All nine terms, horizontal and transposed. √2 has never read our code.

Reading a second solution straight off the answer

Under full clues, a single domino can never change state silently:
flipping a magnet moves the ± counts of the two lines it crosses, and
toggling magnet ↔ neutral moves every line it touches. The tests prove this
exhaustively — every domino, every alternative state, on a stream of random
boards. So the cheapest ambiguity is a pair: two parallel dominoes on the
same two tracks trading states so that all four line counts balance.

Scanning a finished grid for such a pair — no search, no solver — explains
a large share of all non-uniqueness, with zero false alarms:

n non-unique boards explained by one pair certificates on unique boards
4×4 92 34 (37.0%) 0
6×6 83 39 (47.0%) 0
8×8 71 29 (40.8%) 0

And probe ⇔ unique held on the whole stream: 680 boards, no exception in
either direction
.

Takeaways

  • A line's clue pair splits into a sum and a difference, and the difference is structurally blind to in-line dominoes — it is a signed flux through the line's boundary.
  • The anisotropy dial runs uniqueness 0% → 50% → 0% with the clue count fixed: the orientation of the tiling decides how much the same numbers say.
  • Neutral-is-always-legal makes the filling generator dead-end-free as a theorem, not a retry statistic; its density dial is easy at both ends and hard in the middle.
  • Two incomparable middle rungs under one exact roof: ablation leaves the fixpoint bit-identical without any cheap rule, while −pole doubles the roof's work.
  • The raw engine reproduces the √2 convergent numerators (A001333) on strips, nine terms, and matched the propagating engine 462/462.
  • A tiny impossibility theorem (no silent single-domino move) turns into a pair certificate that explains ~40% of non-uniqueness with zero false positives.
  • probe ⇔ unique: 680 boards, no exceptions. 31 tests.

All code is public: https://github.com/sen-ltd/magnets

Top comments (0)