Backtracking Solver Lab
Explore deterministic Sudoku and N-Queens constraint solving locally
About
Enter a Sudoku puzzle or choose an N-Queens board size. The local solver uses minimum remaining values for Sudoku, displays the first N-Queens solution, counts all solutions through N=8, and reports assignments, backtracks, and search nodes.
Examples
Contradictory row rejected
solveSudoku([5, 5, 0, ...79 more]){ solved: false, reason: "invalid" }Two 5s in one row can never satisfy Sudoku rules, so validation fails before search.
4-queens has 2 solutions
solveNQueens(4){ solved: true, solutionCount: 2, firstSolution: [...] }The 4x4 board admits exactly two placements up to the tool's full counting (size <= 8).
About this tool
Backtracking Solver Lab searches constraint problems with solveSudoku(grid) and solveNQueens(size): Sudoku takes an 81-number grid (0 = empty) under MRV search (minimum-remaining-values cell choice), returning solved, grid, steps (assign/backtrack with candidates), assignments, backtracks, nodes, and reason invalid/no-solution. N-Queens takes size 1–14 via row-by-row placement with queenSafe diagonal checks.
Sudoku validation is strict: wrong length, non-integers, out-of-range values, or any given that already violates row/column/box rules returns reason invalid with zero search. N-Queens counts every solution only for size <= 8 (N=8 yields 92 with the first solution exposed); larger sizes return the first solution with solutionCount null.
Search is fully deterministic: the same puzzle always yields the same grid and step log, given cells are never overwritten, and isValidSudokuSolution independently verifies any completed grid.
How to use this tool
Enter the puzzle or board size
Provide 81 Sudoku values (0 for blanks) or an N-Queens size between 1 and 14.
Run the solver
Solve once — read solved plus reason (invalid means the givens already clash).
Replay assign/backtrack steps
Walk steps to see MRV cell picks, candidate lists, assignments, and where backtracks unwind.
Verify the result
Confirm givens are untouched and run isValidSudokuSolution (or check firstSolution for queens).
Use cases
Visualizing MRV search
Show how picking the most-constrained cell first cuts assignments versus naive order.
Checking puzzle validity
Distinguish an invalid given set from a valid-but-unsolvable grind via the reason field.
Enumerating small queen boards
Count all solutions for N <= 8 (N=4 gives 2, N=8 gives 92) and inspect the first layout.
Common mistakes
Mistake:Reading reason invalid as search exhausted the space.
Fix:Invalid means the input givens already break Sudoku rules — no search ran. Only no-solution means a valid grid with no completion.
Mistake:Expecting solutionCount for large N.
Fix:Sizes above 8 return solutionCount null by design (combinatorial explosion) — only solved/firstSolution plus placements/backtracks/nodes are reported.
Frequently asked questions
What does this tool do?
It solves constraints with solveSudoku (81-cell grid, MRV search, assign/backtrack steps with candidates, assignments/backtracks/nodes stats) and solveNQueens (size 1–14, full counting for size <= 8 — N=4 gives 2, N=8 gives 92), plus isValidSudokuSolution verification.
What is the difference between invalid and no-solution?
invalid means the givens already violate Sudoku rules (e.g. two 5s in a row) so no search ran; no-solution means a rule-clean grid that still has no completion. Both return solved false.
Is my puzzle uploaded or stored?
No. Validation, MRV search, and queen placement run fully client-side and deterministically.
Why is solutionCount null for large N?
Full counting is capped at size <= 8 to avoid combinatorial explosion — larger boards still return solved and firstSolution with placements/backtracks/nodes, but solutionCount is null.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML