Sudoku

Self‑contained Sudoku solver (JS only). Paste a puzzle, click Solve, and inspect correctness in the harness.

What this is?

A clean, browser‑only Sudoku implementation inspired by the same case study. It supports text or grid input and uses constraint propagation (naked & hidden singles) plus backtracking with a smallest‑domain heuristic, guaranteeing a solution if it exists.

Input: digits 1–9; use ., 0 or a space for blanks. Length 81 if pasted as a line.

Grid

Text

Syncs both ways. Pasting 9 lines is fine; we’ll strip whitespace.

Answer

Reason why

We represent candidates as a 9‑bit mask per cell. Propagation removes digits already seen in peers (same row/column/box) and applies hidden singles per unit when a digit can go in exactly one place.

When stuck, we pick the cell with the fewest candidates and try them in order (depth‑first). Each guess triggers another round of propagation. This is complete and typically fast for standard puzzles.

Check (harness)