Sudoku Solver

Port of the original Python solver from my BSc project

Hint Insight

No active hint.

Press Show Hint to detect the next logical step in the same method order used by the solver.

Result

Ready.

Method Guide

Reference for the pen and paper methods and order used in this solver.

Core Terms

House
Any row, column, or box.
Candidate
A value that is not yet ruled out for a cell.
Reason Cells
Cells highlighted to explain why a hint is valid.
Target Cells
Cells that will be filled or reduced by that hint.

How To Read Hint Insight

  • Method code maps to one solver stage (for example n-sin or h-sub).
  • Fill hints place a forced value directly in a cell.
  • Elimination hints remove impossible candidates; values are unchanged until a fill is forced.
  • Loop behavior: after any successful step, the solver restarts at n-sin.

Naked Single

n-sin

A cell with only one remaining candidate must take that value.

  • Spot it: candidate list length is exactly 1.
  • Action: fill the cell and propagate constraints across its row, column, and box.
  • Why it works: no alternative value remains for that cell.
  • Beginner tip: this is the fastest and most reliable first scan on every pass.

Hidden Single

h-sin

A candidate that appears in only one cell of a house is forced.

  • Spot it: check each digit in one house and count positions.
  • Action: fill the only cell where that digit can go.
  • Why it works: every house must contain each value exactly once.
  • Beginner tip: this can occur even when a cell has multiple candidates.

Box-Line Intersection

b-l-int

Locked candidates in a row/column and box intersection eliminate peers outside that overlap.

  • Spot it: all candidates for a digit in a line are confined to one box, or all candidates in a box are confined to one line.
  • Action: remove that digit from the other cells of the linked house outside the intersection.
  • Why it works: one of the intersection cells must contain the digit.
  • Beginner tip: this is an elimination method; it usually prepares future singles.

Naked Subset

n-sub

If X cells in one house contain only X shared digits, those digits are locked to that group.

  • Spot it: a pair/triple/quad pattern where the union of candidates has size X.
  • Action: remove subset digits from all other cells in the same house.
  • Why it works: subset digits must occupy the subset cells in some order.
  • Beginner tip: candidate lists do not need to be identical; only the union-size rule matters.

Hidden Subset

h-sub

If X digits appear only inside X cells of a house, those cells must be those digits.

  • Spot it: track digit positions in a house and find candidate sets whose span equals set size.
  • Action: strip non-subset digits from the spanned cells.
  • Why it works: the subset digits cannot be placed anywhere else in that house.
  • Beginner tip: this implementation includes complex hidden subsets, not only easy pair patterns.

Branching Tree

search

When logical methods stall, the solver guesses systematically with backtracking.

  • Spot it: no method from n-sin through h-sub can progress.
  • Action: try candidates, apply logic, reject branches that produce contradictions, continue recursively.
  • Why it works: invalid branches are pruned, so valid branches converge to one or more full solutions.
  • Beginner tip: enable Find All Solutions to keep exploring after the first valid solution.

Solver Chain Order

  1. 1. n-sin Fill every naked single currently available.
  2. 2. h-sin Fill hidden singles by scanning houses.
  3. 3. b-l-int Apply locked-candidate eliminations on box-line overlaps.
  4. 4. n-sub Remove candidates using naked subset structures.
  5. 5. h-sub Remove candidates using hidden subset structures.

If any step makes progress, restart from step 1. If no logical step applies, optional branching starts. This mirrors the original solver behavior.