The goal is a picture in which every row and column matches its clue, the lengths of its runs of filled cells in order. Click or drag to fill a cell. Right-click, shift-click or CROSS mode marks a cell as empty.
PICK A PICTURE loads a puzzle, and RANDOM makes one with exactly one solution. A clue turns green once the marks already meet it.
SOLVE runs the chosen method and, for SAT and hybrid, replays its search. DEDUCE shows the cells that line solving can prove, and HINT names one forced cell with its reason.
A nonogram gives one clue per row and one per column. A clue is the list of lengths of the runs of filled cells in that line, in order: the clue 3 1 means a run of three filled cells, at least one empty cell, then a run of one. The page solves a puzzle in three ways. Line solving reads one row or column at a time and proves the cells it can. The SAT method writes the whole grid as a propositional formula and searches it with DPLL. The hybrid method combines line solving with guesses and backtracking. Uniqueness, hints and the random generator build on these.
A line of n cells is a string of 0s (empty) and 1s (filled). The strings that satisfy a clue form a regular language, and a small deterministic finite automaton (DFA) recognises exactly that language. A DFA has a set of states, a start state, a set of accepting states, and at most one successor for each state and symbol. A missing successor is a dead move, written \bot. For a clue with m runs of lengths L_0, \dots, L_{m-1}, the states are A_k (k runs are finished and none is open, for 0 \le k \le m), B_{k,j} (inside run k, with j of its cells filled, for 1 \le j < L_k), and D_{k+1} (run k has just been completed, so the next cell must be empty). The automaton has \sum_k L_k + m + 1 states. For k = m, reading a 1 from A_m is a dead move, because no run is left to open. Its start state is A_0, and it accepts when it ends in A_m or D_m. A clue with no runs accepts only the all-empty line.
Here \delta(s, v) is the successor of state s on symbol v. Reading an empty cell from A_k stays in A_k, and reading a filled cell opens run k. A run cannot be cut short, so an empty cell inside a run is a dead move. A completed run must be followed by an empty cell, so a filled cell after D_{k+1} is a dead move. These rules are what stop two runs from touching. The automaton is deterministic, so each word follows exactly one path through it.
Example. The clue 3 1 has the states A_0, A_1, A_2, B_{0,1}, B_{0,2}, D_1, D_2, which is 4 + 2 + 1 = 7 states. The line 11101 is read as A_0 \xrightarrow{1} B_{0,1} \xrightarrow{1} B_{0,2} \xrightarrow{1} D_1 \xrightarrow{0} A_1 \xrightarrow{1} D_2, which ends in an accepting state. The same clue on a line of 5 cells has only this one arrangement, since 3 + 1 + 1 = 5 cells are needed.
A clue fits a line of n cells only when there is room for its runs and one empty separator between neighbours. The page checks this before solving, with \sum_k L_k + \max(0, m-1) \le n. For a clue that fits, the state count is at most n + 2, because \sum_k L_k + m - 1 \le n. That bound keeps every line sweep small.
Here L_k is the length of run k, m is the number of runs and n is the length of the line. The sum counts the filled cells, and the m - 1 separators are the empty cells between neighbouring runs.
Line solving asks, for each cell, which values it can take in some arrangement that fits the clue and the cells already known. It does not list the arrangements, of which there can be exponentially many. It runs two sweeps over the automaton instead. The forward sweep F_i is the set of states reachable after reading the first i cells. The backward sweep B_i is the set of states from which cells i onward can still be completed to an accepted line. V_i is the set of values that cell i may take: \{0, 1\} when the cell is unknown, and only its known value otherwise. Each sweep visits each position and state once.
Here \text{Acc} is the accepting set, and the sets never contain \bot. The known value of cell i is c_i \in \{-1, 0, 1\}, where -1 means unknown, so V_i = \{0, 1\} when c_i = -1 and V_i = \{c_i\} otherwise. Cell i can take value v when some state in F_i moves on v into B_{i+1}. That joins a fitting prefix, cell i equal to v, and a fitting suffix, which together form a full arrangement. The possible values are stored as a bitmask P_i, with bit v set when value v is possible.
Bit 0 is EMPTY_OK (value 0 is possible) and bit 1 is FILLED_OK (value 1 is possible). A mask of 2 forces the cell filled, a mask of 1 forces it empty, and a mask of 3 leaves it unknown.
Each run also gets its valid start positions. Let A_k be the state with k runs finished, just before run k opens. Run k can open at cell s when that cell is not known to be empty, the automaton can be in A_k before s, and the state after reading a filled cell can still be completed from s + 1. Write S_k for the set of such starts over all fitting arrangements.
Every arrangement places run k on the cells from its start to its start plus L_k - 1. The cells covered by run k in every arrangement are therefore the cells from the latest possible start, \max S_k, to the earliest possible start plus the length, \min S_k + L_k - 1. This is the overlap, and it is empty when the first cell comes after the last.
Example. The clue 4 on 6 cells can start at cells 0, 1 or 2 (the run must end by cell 5), so S_0 = \{0, 1, 2\}. The overlap is [2, 3] from zero-based indexing, so the third and fourth cells are filled in every arrangement. Cells 0 and 1 are not forced.
function ANALYSE-LINE(clue, known):
forward ← states reachable from the start, reading only the known cells
backward ← states that can still reach an accepted end
consistent ← the start state is in backward[0]
for each cell i:
possible[i] ← the values v that take some forward state to a backward state
for each run k:
starts[k] ← the positions where run k can begin in some arrangement
return consistent, possible, starts
function ANALYSE-LINE(clue, known): # known[i] = −1 unknown, 0 empty, 1 filled
aut ← BUILD-AUTOMATON(clue) # states A[k], B[k,j], D[k]; start is A[0]
# ALLOWED(c) is (0, 1) when c = −1, else (c)
n ← length of known
forward[0] ← {start}
for i = 0 to n − 1: # forward sweep
for each state s in forward[i]:
for each v in ALLOWED(known[i]): # (0, 1) if unknown, else (known[i])
if δ(s, v) ≠ DEAD:
add δ(s, v) to forward[i + 1]
backward[n] ← accepting states
for i = n − 1 down to 0: # backward sweep
for each state s:
for each v in ALLOWED(known[i]):
if δ(s, v) ≠ DEAD and δ(s, v) in backward[i + 1]:
add s to backward[i]
break # one allowed value is enough
consistent ← start in backward[0]
for i = 0 to n − 1: # possible values of each cell
mask ← 0
for each state s in forward[i]:
for each v in ALLOWED(known[i]):
if δ(s, v) ≠ DEAD and δ(s, v) in backward[i + 1]:
mask ← mask OR 2^v # bit 0: 0 possible, bit 1: 1 possible
possible[i] ← mask
for k = 0 to m − 1: # valid starts of run k
opened ← A[k]
after ← δ(opened, 1)
starts[k] ← empty list
if after ≠ DEAD:
for s = 0 to n − 1:
if known[s] ≠ 0 and opened in forward[s] and after in backward[s + 1]:
append s to starts[k]
return consistent, possible, starts
The forward sweep keeps only prefixes that fit the clue so far. The backward sweep keeps only states that can still be completed, so the cell test in the middle joins a fitting prefix to a fitting suffix. Without the backward sweep, a prefix could look valid and still have no way to finish the line.
The break in the backward sweep is only a shortcut: one allowed value that leads somewhere is enough to keep the state. The valid starts use the same two sweeps, so the overlap and the forced cells always describe the same set of arrangements.
A line pass runs ANALYSE-LINE on every row, then on every column, and writes each forced cell into the grid. Each write is seen by later lines. Rounds of passes repeat until a full round changes nothing. The grid at that point is a fixed point: no single line can prove another cell from the cells known so far. If any line has no fitting arrangement, the grid is contradictory, and the pass reports it at once.
The DEDUCE button replays this process. The server returns each pass with the cells it fixed, and the page paces the lines so the whole run takes about 1.4 s, with each line between 20 and 120 ms. Cells appear in green as they are proved.
Here \text{steps} is the number of lines that fixed at least one cell, and the delay is the time between two lines. The clamp keeps the whole run between 20 and 120 ms per line.
function PROPAGATE-LINES(grid):
repeat:
for each row and column:
fill every cell that ANALYSE-LINE proves
if the line cannot fit its clue: return false
until nothing changes
return true
function PROPAGATE-LINES(grid):
repeat:
progressed ← false
for each axis in (rows, columns):
for each line idx of that axis, in order:
known ← the cells of line idx, read from grid
consistent, possible, starts ← ANALYSE-LINE(clue of line idx, known)
if not consistent:
return false # no arrangement fits: a contradiction
fixed ← empty list
for each cell i with known[i] = −1:
if possible[i] = 2: # only 1 is possible
grid[cell i] ← 1
add cell i to fixed
else if possible[i] = 1: # only 0 is possible
grid[cell i] ← 0
add cell i to fixed
if fixed is not empty:
record the pass for the DEDUCE replay
progressed ← true
until progressed is false
return true
The fixed point is the non-obvious idea. A cell that one line cannot decide may become decided after a crossing line has fixed its neighbours, so the sweep runs until no line changes anything. The loop always stops, because each round can only turn unknown cells into known cells, and there are finitely many cells.
Line solving alone finishes a puzzle when the fixed point leaves no unknown cell. When it stops early, the rest needs a search, which is what the SAT and hybrid methods provide.
The SAT method turns the whole puzzle into conjunctive normal form (CNF). A CNF formula is a list of clauses, each a disjunction (an OR) of literals, where a literal is a variable or its negation. An assignment satisfies the formula when every clause has at least one true literal. Each cell (r, c) has a variable x_{rc}, true when the cell is filled. Each line has its own automaton variables: s_{i,q} is true when the line's automaton is in state q after i cells. Only states that are both reachable from the start and able to reach acceptance get a variable, which keeps the formula small13. The row and the column that share a cell use the same x_{rc}, so the two lines agree on it.
A transition variable y marks one step of the automaton: it is true when the line is in state q at position i, cell i has the value v, and the automaton moves to state t. Let \ell_{i,v} be the literal "cell i equals v", which is x_i when v = 1 and \neg x_i when v = 0. The clauses below make the state sequence a witness that the clue holds.
The first clause sets the start state, and the second rules out every other start. The last clause says that at least one accepting state is true after cell n. An empty clause here means that no fitting line exists at this length, and makes the formula unsatisfiable.
A dead move, one that leads to a state that cannot finish, is forbidden by a single clause. A live move gets a transition variable y, and the three clauses on the right make y exactly equal to s_{i,q} \wedge \ell_{i,v}. The two directions matter. The first two clauses make y true only when the state and the cell agree, and the third makes it true whenever they do.
The first clause sets the successor state t when the transition is taken. The second says that s_{i+1,t} can be true only if some transition y \to t into t is taken. Without it, the solver could make a state true with no path that reaches it. Because the automaton is deterministic, the state sequence is forced once the cells are fixed, so the satisfying assignments are exactly the pictures whose lines all fit their clues.
Example. The 5-cell line with clue 3 1 has only one arrangement, 11101, so the only satisfying assignment of its cell variables is that line. The encoding for that line is one automaton path, and the formula has no other solution for it.
function ENCODE-LINE(clue, cells):
keep the automaton states that are reachable and can still finish
give each kept (position, state) pair a variable
add clauses: start in the start state, one accepting state at the end
for each position and kept state:
add clauses that force the next state for each cell value
forbid moves that lead to a dead state
function ENCODE-LINE(clue, x[0..n−1]):
aut ← BUILD-AUTOMATON(clue)
forward, backward ← REACH-SETS(aut, n) # no cell is known yet
for i = 0 to n:
live[i] ← forward[i] ∩ backward[i] # reachable from the start and able to finish
if start not in live[0]:
add the empty clause; return # no accepted line exists at this length
for i = 0 to n:
for each q in live[i]:
create variable s[i][q]
add clause (s[0][start])
for each q in live[0] other than start:
add clause (¬s[0][q])
for i = 0 to n − 1:
for each t in live[i + 1]:
incoming[t] ← empty list
for each q in live[i]:
for v in (0, 1):
t ← δ(q, v)
ℓ ← x[i] if v = 1, else ¬x[i] # the literal "cell i = v"
if t = DEAD or t not in live[i + 1]:
add clause (¬s[i][q] or ¬ℓ) # from q, value v leads nowhere
else:
create variable y
add clause (¬y or s[i][q])
add clause (¬y or ℓ)
add clause (y or ¬s[i][q] or ¬ℓ) # y ↔ (s[i][q] and ℓ)
add clause (¬y or s[i + 1][t])
append y to incoming[t]
for each t in live[i + 1]:
add clause (¬s[i + 1][t] or every y in incoming[t])
add clause (every s[n][q] with q accepting) # an empty clause means never accepted
The live filter is the non-obvious step. A state that is reachable from the start but cannot reach acceptance gets no variable. Any move into such a state is then a dead move, and a dead-move clause forbids it. Without the filter the formula would still be correct, but it would carry variables that can never be part of a satisfying assignment.
The formula has one variable per live (position, state) pair, and one more per live transition. Each live transition adds four clauses, and each live state at the next position adds one incoming clause. The page shows these totals as VARIABLES and CLAUSES in the search view, next to the decision, conflict, backtrack and propagation counters.
DPLL (Davis, Putnam, Logemann and Loveland) is a backtracking search for a satisfying assignment of a CNF formula. It alternates two steps. Unit propagation finds a clause whose literals are all false except one unassigned literal, and sets that literal true, because the clause would otherwise be false. It repeats until no such clause remains. When propagation is finished, the solver makes a decision: it picks an unassigned variable and gives it a value. A clause whose literals are all false is a conflict. The solver then undoes the most recent decision that has not yet been tried both ways.
This solver has no clause learning, so it is DPLL and not CDCL. Its backtracking is chronological: it undoes decisions in the order they were made and never records a conflict as a new clause. That keeps the code short, and the cost is that the same conflict can be rediscovered many times.
A pure literal is a variable that appears with only one sign in the remaining clauses. Setting it to that sign satisfies every clause it appears in and cannot make the formula unsatisfiable, so the solver removes pure variables once, before the search. Each clause of two or more literals watches two of them. A clause is visited only when one of its watched literals becomes false, so most clauses are never touched during propagation.
Decisions use VSIDS, the variable state independent decaying sum heuristic, in a simplified form. Each variable has an activity, which rises whenever the variable appears in a conflict clause. The rise is an increment that grows after every conflict, so recent conflicts weigh more than old ones. The variable with the highest activity among the unassigned ones is decided next. Cell variables start with activity 1.0 and helper variables with 0, so the search decides the picture before the automaton helpers.
Here a(v) is the activity of variable v, and t counts conflicts from 1. The code adds the current increment to each variable in the conflict clause, then divides the increment by 0.95. So the increment before conflict t is 0.95^{-(t-1)}, which is the same as multiplying old activities by 0.95. The decay constant 0.95 is the value MiniSat uses for its VSIDS decay19.
When the increment passes 10^{100}, every activity and the increment are multiplied by 10^{-100}. This keeps the floats in range without changing the order of the activities.
Phase saving means that when backtracking unassigns a variable, its last value is saved, and the next decision on that variable uses the saved value. Before any decision, a variable's phase is false, which is the negative literal.
function DPLL(clauses, cell-variables):
remove pure variables and the clauses they satisfy
repeat:
propagate: every clause with one unassigned literal forces that literal
if a clause is all false (a conflict):
undo the newest decision that has not been tried both ways
if none is left: return UNSAT
try its other value
else if every variable is assigned: return SAT
else: decide the unassigned variable with the highest activity, using its saved phase
constants: DECAY = 0.95, PRIOR = 1.0 # cell variables start at PRIOR
function DPLL-SOLVE(clauses, cell-variables, propagation-budget, deadline):
fixed ← PURE-ELIMINATE(clauses) # variable → sign, repeated until none is pure
for each variable v in fixed:
ASSIGN the literal of v with its sign # level 0: never undone
for each clause c:
remove duplicate literals
if c is empty: return UNSAT
if c has one literal ℓ:
if ℓ is false: return UNSAT
if ℓ is unassigned: ASSIGN(ℓ)
else if c holds a variable and its negation:
skip # always true
else:
watch the first two literals of c
activity[v] ← PRIOR for each cell variable, 0 otherwise
heap ← every variable, keyed by activity
if PROPAGATE() finds a conflict: return UNSAT
repeat:
if the clock is past deadline: return UNKNOWN
conflict ← PROPAGATE()
if conflict is not none:
conflicts ← conflicts + 1
BUMP(conflict)
while the newest decision is flipped: # both of its values have failed
pos ← that decision's trail position
UNDO(pos); remove the decision
if no decision is left: return UNSAT
(pos, ℓ, flipped) ← newest decision
UNDO(pos)
replace the decision by (pos, ¬ℓ, flipped = true)
ASSIGN(¬ℓ) # the forced negation
else if propagations > propagation-budget:
return UNKNOWN
else:
v ← PICK()
if v = 0: return SAT # every variable is assigned
ℓ ← phase[v]
push decision (trail length, ℓ, flipped = false)
ASSIGN(ℓ)
function PROPAGATE():
while the trail has an unprocessed literal ℓ: # ℓ has just become true
for each clause c that watches ¬ℓ: # ¬ℓ has just become false
if the first watch of c is true: # satisfied by its other watch
keep watching ¬ℓ; continue
if some other literal of c is not false:
watch that literal instead of ¬ℓ # c leaves ¬ℓ's watch list
continue
if the first watch of c is false:
return c # every literal is false: conflict
ASSIGN(the first watch of c) # unit: the last literal is forced
return none
function BUMP(c):
for each variable v in c:
activity[v] ← activity[v] + inc
inc ← inc / 0.95
if inc > 10^100: # rescale before floats overflow
activity[v] ← activity[v] × 10^−100 for every v
inc ← inc × 10^−100
function UNDO(pos):
while the trail is longer than pos:
ℓ ← remove the last literal from the trail and unassign it
phase[variable of ℓ] ← ℓ # phase saving
push the variable of ℓ onto heap with its activity
function PICK():
while heap is not empty:
v ← pop the entry with the highest activity
if v is unassigned: return v
return 0
function PURE-ELIMINATE(clauses):
fixed ← empty map
repeat:
pure ← variables that occur with exactly one sign
if pure is empty: stop
add pure to fixed
remove every clause that contains a variable of pure
return fixed
Watched literals are the reason propagation is fast21. A clause keeps two watches, and it is inspected only when one watch becomes false. The code swaps the false literal into the second slot, looks for a replacement watch among the other literals, and removes the clause from the old watch list with a swap-and-pop, which is constant time. A clause is unit only when no replacement exists and its other watch is unassigned.
Flipped decisions are the non-obvious part of backtracking22. Each decision is stored with a flag. When a conflict undoes a decision whose negation has also failed, the flag tells the solver to keep undoing before it tries anything new. The first decision that has not been tried both ways is then given its negation, and it is marked flipped so that a later conflict will undo it.
The search stops with UNKNOWN in two cases: the propagation count passes the budget, or the wall clock passes the deadline. The deadline is checked once per loop turn, so the solver can overshoot by one propagation round and one decision. The clock is not read while the formula and its watch lists are built, so that setup time comes before the first check. For one 25 × 25 random picture this setup took 1.2 s in a measurement on a heavily loaded machine. The server reports a stop as undecided, and the benchmark runs without a deadline.
Hybrid is a depth-first search with line propagation at every node. Each node first runs line passes to a fixed point. If cells are still unknown, the search makes a guess. It picks the line with the fewest unknown cells among the lines that have any, with rows first on ties. It takes the first unknown cell of that line and tries 1, then 0. The code's comment says that guessing on this line collapses the most arrangements per guess. A backtrack is counted when a guess leads to no new solution.
Here u(\ell) is the number of unknown cells in row or column \ell, and the minimum is taken over the lines that still have an unknown cell. A node where no unknown cell is left is a solution. Propagation has already checked every line against its clue, so the solver also verifies the grid against the clues before reporting it.
Every node checks two limits before it does any work. The guess budget is 2,000 guesses on the server. The deadline is 10 s of wall-clock time, which the server passes in. Passing either one ends the search with the status undecided24. The server sets both limits25.
function SEARCH(grid):
if not PROPAGATE-LINES(grid): return # a line cannot fit: undo the guess
if grid is full: record it as a solution; return
(r, c) ← first unknown cell of the line with the fewest unknowns
for v in (1, 0):
SEARCH(grid with cell (r, c) set to v)
function HYBRID(puzzle, limit, guess-budget, deadline):
solutions ← empty list
try:
SEARCH(empty grid)
on guess budget reached:
stop # undecided: the guess budget ran out
on time-limit reached:
stop # undecided: the wall clock passed the deadline
return solutions
function SEARCH(grid):
if |solutions| ≥ limit: return
if guesses > guess-budget: raise guess budget reached
if the clock is past deadline: raise time-limit reached # checked at every node
if not PROPAGATE-LINES(grid):
conflicts ← conflicts + 1
return
best ← none
for each row r:
u ← number of unknown cells in row r
if u > 0 and (best is none or u < best.u): best ← (u, row, r)
for each column c:
u ← number of unknown cells in column c
if u > 0 and (best is none or u < best.u): best ← (u, column, c)
if best is none:
add a copy of grid to solutions
return
(r, c) ← first unknown cell of best
for v in (1, 0): # filled first, then empty
child ← copy of grid with cell (r, c) = v
guesses ← guesses + 1
before ← |solutions|
SEARCH(child)
if |solutions| ≥ limit: return
if |solutions| = before: # this guess led to no new solution
backtracks ← backtracks + 1
The limit is 2 for both the solve and the uniqueness count, so the search stops at the second solution. The guess budget and the deadline are both exceptions that unwind the whole search, not just one branch. That is why the handlers sit at the top of HYBRID, and why a stopped run can still report the solutions it found before it stopped.
The code checks the budget before the propagation, so a node that is over budget does no work. The cost of one node is a few line passes, which is tens of milliseconds on a 25 × 25 picture. That is why the clock is read at each node: one read is negligible next to the work.
A good puzzle has exactly one picture that fits its clues. The page checks this by finding one solution and then asking for a different one. SAT does it with a blocking clause: a clause that is false on exactly the first picture, so the solver must find a picture that differs in at least one cell. If that second solve is unsatisfiable, the first picture is the only one. The hybrid method instead counts solutions with a limit of two, and stops at the second.
The blocking clause is the OR over the cells of the first solution: a filled cell must become empty, or an empty cell must become filled. A puzzle with two solutions is reported as multiple, and the page then offers the other picture as SECOND ANSWER. A puzzle with no solution is reported as a contradiction, which the page shows as NO SOLUTION.
Every solution is checked against the clues before it is reported28. A failed check raises an error, because it would mean a bug in the solver rather than a wrong answer for the player.
A uniformly random grid is a poor puzzle, because most random pictures have many solutions: nothing ties neighbouring cells together. So the generator draws smooth random blobs. It sets a random value on a coarse grid, with one value for about every 3 cells, then interpolates each cell's value from the four coarse points around it. Interpolation here is bilinear: it blends the two coarse points on each side horizontally, then blends those two results vertically. A cell is filled when its value is at least 0.5. A picture is kept only when its filled fraction is between 30% and 70%, and then the hybrid search must find exactly one solution within a budget of 300 guesses29. The seed fixes every draw, so the same seed always gives the same puzzle.
Here R and C are the rows and columns of the picture, g_R and g_C are the sizes of the coarse grid, and u_{ij} is a uniform random number in [0, 1) on that grid. y_r and x_c locate the cell in coarse-grid units, and y_0, x_0 pick the coarse square around it. f_r, f_c are the fractions across that square. The value is blended first horizontally, between the two coarse points of each coarse row, then vertically. The brackets in the cell formula are 1 when the condition holds and 0 otherwise.
function RANDOM-PUZZLE(rows, cols, seed):
repeat up to 40 times:
picture ← a random blobby picture
if its filled fraction is outside 30% to 70%: try again
if the hybrid search finds exactly one solution within 300 guesses:
return the clues
raise no-unique-picture
function RANDOM-PUZZLE(rows, cols, seed):
if seed is none: seed ← a random integer below 2^31
rng ← random number generator seeded with seed
for attempt = 1 to 40:
picture ← RANDOM-PICTURE(rows, cols, rng)
filled ← number of 1 cells in picture
if filled / (rows × cols) < 0.30 or > 0.70:
continue # too sparse or too dense
puzzle ← clues of picture
(status, _, _) ← COUNT-SOLUTIONS(puzzle, limit = 2, guess-budget = 300)
if status = unique:
return (puzzle, seed, attempt)
raise no-unique-picture
function RANDOM-PICTURE(rows, cols, rng):
g_R ← ceil(rows / 3) + 1
g_C ← ceil(cols / 3) + 1
coarse[i][j] ← rng uniform in [0, 1), for i < g_R and j < g_C
for r = 0 to rows − 1:
y ← r × (g_R − 1) / (rows − 1)
y0 ← min(floor(y), g_R − 2)
fy ← y − y0
for c = 0 to cols − 1:
x ← c × (g_C − 1) / (cols − 1)
x0 ← min(floor(x), g_C − 2)
fx ← x − x0
top ← coarse[y0][x0] × (1 − fx) + coarse[y0][x0 + 1] × fx
bottom ← coarse[y0 + 1][x0] × (1 − fx) + coarse[y0 + 1][x0 + 1] × fx
value ← top × (1 − fy) + bottom × fy
picture[r][c] ← 1 if value ≥ 0.5 else 0
return picture
The generator draws a new coarse grid on every attempt, so the attempts are independent. A rejected picture costs at most about one second, because the uniqueness check is capped at 300 guesses. The check is the expensive part, and the density test runs first so that the check is skipped for pictures that are clearly too sparse or too dense.
HINT uses only the line analysis, with no search. It first checks every line against the marks. If one cannot fit, the hint names that line as a contradiction, so the player can look for the wrong mark there. Otherwise it scans the rows, then the columns, and reports the first unknown cell that ANALYSE-LINE forces34. Each hint also gives a reason. If the cell is filled, the reason is the run whose overlap covers it, and the longest such run is named. If the cell is empty, the reason is that no arrangement puts a run on it35.
HINT does not fill the cell. It only shows it, and APPLY HINT writes the value into the marks.
Each budget is a count of work, not seconds, so a result does not depend on the speed of the machine36. The time limit is the exception. It is wall-clock, and it is the limit that binds on large pictures, because the cost of one hybrid guess grows with the picture. A stopped run reports the status undecided, and the page says whether a time limit or a budget did it.
The SAT budget comes from a measurement on 25 × 25 random pictures: DPLL did about 0.7 million propagations per second, so 6 million propagations is about 8 s, and the server's 10 s limit usually binds first. The code's estimate for the hybrid guess budget is 10 to 50 s of search.
| PARAMETER | VALUE | USED BY |
|---|---|---|
| VSIDS decay | 0.95 per conflict | DPLL branching (SAT) |
| Initial activity | 1.0 for cell variables, 0 for automaton helpers | DPLL branching (SAT) |
| Default phase | false, then phase saving | DPLL (SAT) |
| Time limit, server solve | 10 seconds, wall clock | SAT and hybrid solves (the line method is one pass and ignores it) |
| Propagation budget, server SAT | 6,000,000 implied literals | SAT solve endpoint |
| Propagation budget, benchmark | 5,000,000 implied literals | benchmark runs |
| Guess budget, server hybrid | 2,000 guesses | hybrid solve endpoint |
| Replay events | 4,000 recorded, shown in at most 150 ticks of 40 ms | search view on this page |
| Random noise | one value per 3 cells, bilinear, threshold 0.5 | random generator |
| Random density | 30% to 70% filled | random generator |
| Random attempts | up to 40 pictures | random generator |
| Uniqueness guess budget | 300 guesses per check | random generator |
| Sizes | 5 to 20 per side for random; the solver takes 1 to 25 | picker and random generator |
| Concurrent solves | 2 at a time, waiting up to 5 s | solve endpoints |
| Solve rate | 30 requests per minute per client | solve and random endpoints |
| Hint rate | 120 requests per minute per client | hint endpoint |
How a run is shown. The server records up to 4,000 search events37: decisions with their cell and value, conflicts, and backtracks. The page plays them back in at most 150 ticks of 40 ms, which is about 6 s. Events are not recorded for propagations, so that counter shows "…" during the replay. When the replay ends, the exact totals from the server replace the running numbers. If the event list was capped, the counters are still the full run.
The count budgets are backstops for small pictures, and the time limit binds first on large ones. The server's rates are set in 38, and the sizes come from 39 and 40. A budget or time limit that is hit is reported as undecided, so a slow case never returns a wrong answer.
The decay of 0.95 follows MiniSat's VSIDS, as the code comment says. The random noise and density values are the generator's own choices.
The committed benchmark runs all three methods on the first 12 library pictures (pictures added to the library later are not in it)41 and on 30 seeded random pictures, 10 each at 10 × 10, 15 × 15 and 20 × 2042. Line solving alone finishes 39 of the 42 puzzles. The three it does not finish are the library pictures smiley and rocket and one random 20 × 20 picture. Hybrid and SAT both finish all 42, with no undecided run. The times are wall-clock on the machine that wrote the results file, so they are a relative guide, not a fixed measure43.
| Group | Puzzles | Line alone finishes | Hybrid median s | Hybrid max s | SAT median s | SAT max s |
|---|---|---|---|---|---|---|
| Library | 12 | 10 | 0.0104 | 0.1144 | 0.1235 | 3.3978 |
| Random 10×10 | 10 | 10 | 0.0039 | 0.0078 | 0.0459 | 0.1266 |
| Random 15×15 | 10 | 10 | 0.0127 | 0.0748 | 0.2752 | 0.5564 |
| Random 20×20 | 10 | 9 | 0.0552 | 0.5437 | 1.3794 | 6.2530 |
| All | 42 | 39 | 0.0122 | 0.5437 | 0.1996 | 6.2530 |
Example. Rocket, a 17 × 15 library picture, is the slowest library picture for SAT in the committed run. The encoding has 4,894 variables and 13,825 clauses. DPLL makes 924 decisions and 916 conflicts, with 449,091 propagations, and takes 3.40 s. Hybrid solves the same picture with 6 guesses in 0.011 s, and its line passes fix 427 cells along the way.
The committed run uses fixed seeds. The counts (guesses, conflicts, propagations, backtracks) are deterministic, and only the seconds depend on the machine. Run python -m nonogram benchmark to reproduce the counts.