Introduction
Sudoku is a logic-based number placement puzzle played on a 9x9 grid. The objective is to fill the grid so that each row, each column, and each of the nine 3x3 sub-grids contains the digits 1 through 9 exactly once. This solver uses a backtracking algorithm to find the solution to any valid Sudoku puzzle you enter, instantly and entirely in your browser.
What this tool does
- Solves any valid 9x9 Sudoku puzzle using a backtracking algorithm.
- Accepts input as 81 digits (0 or dot for empty cells) in row-major order, or as a 9-line grid.
- Displays the solved grid in a readable 9x9 format.
- Shows an error message if the puzzle has no solution or is invalid.
- Includes an example puzzle button for quick testing.
How this tool works
Enter the known digits of your Sudoku puzzle in the input field. Use 0 or a dot (.) for empty cells. You can enter all 81 digits on one line, or spread them across 9 lines (one per row). Click Solve and the tool uses a backtracking algorithm to systematically try values for each empty cell, backtracking when a conflict is found, until the grid is complete. The solution appears in the output field formatted as a 9x9 grid. If no solution exists, an error is displayed.
How the Sudoku solver works
The Sudoku solver uses backtracking, a depth-first search algorithm that is the simplest correct method for solving constraint satisfaction problems like Sudoku. The algorithm works as follows: (1) Find the first empty cell. (2) Try placing the digit 1 in that cell. (3) Check if the placement is valid (no duplicate in the same row, column, or 3x3 box). (4) If valid, recursively try to solve the rest of the grid. (5) If the recursion leads to a dead end, undo the placement (backtrack) and try the next digit (2, 3, ..., 9). (6) If no digit works, backtrack further. (7) If all cells are filled, the puzzle is solved. Backtracking guarantees finding a solution if one exists, but can be slow for puzzles with very few clues (17 is the minimum number of clues for a unique Sudoku solution, proven in 2012). More advanced solvers use constraint propagation (naked singles, hidden singles, X-Wing, etc.) to reduce the search space before backtracking, but for standard 9x9 puzzles, plain backtracking is fast enough. Sudoku was popularized by Japanese puzzle publisher Nikoli in 1984 (the name means 'single number' in Japanese) and became an international phenomenon in 2004-2005 after being featured in The Times of London.
How to use this tool
- Enter your puzzle in the input field. Use digits 1-9 for known cells and 0 or . for empty cells.
- You can enter all 81 characters on one line, or use 9 lines (one per row).
- Click the Solve button (or the output updates automatically if the tool supports live mode).
- The solved grid appears in the output field in a readable 9x9 format.
- If the puzzle is invalid or has no solution, an error message is displayed.
Real-world examples
Solving a standard puzzle
Input: `530070000600195000098000060800060003400803001700020006060000280000419005000080079`. The solver fills in all empty cells and displays the complete 9x9 solution grid.
Using dots for empty cells
Input: `53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79`. Dots are treated the same as zeros for empty cells.
Multi-line input
You can enter the puzzle as 9 lines of 9 characters each, which is easier to read and match against a printed puzzle.
Comparison with similar methods
| Method | Complexity | Typical use |
|---|---|---|
| Backtracking (this tool) | O(9^n) worst case, typically fast | General-purpose solving, guaranteed correct |
| Constraint propagation | O(n) per technique pass | Human-style solving, reduces search space |
| Dancing Links (DLX) | O(n) per update, efficient backtracking | Fast solving of many puzzles, exact cover |
| Human techniques | Varies by technique | Enjoyment, puzzle difficulty rating |
Limitations or considerations
The backtracking algorithm can be slow for puzzles with very few clues (close to the 17-clue minimum). The solver finds one valid solution; if multiple solutions exist, it returns the first one found. The tool does not check puzzle uniqueness or difficulty. Input must be exactly 81 cells (9x9); larger or smaller grids are not supported. The solver does not use advanced human techniques (X-Wing, Swordfish, etc.) — it uses pure backtracking.
Frequently asked questions
What is the minimum number of clues for a unique Sudoku solution?
17. This was proven in 2012 by a team of mathematicians using exhaustive computer search. Puzzles with 17 clues can have a unique solution, but puzzles with 16 or fewer clues always have multiple solutions.
How fast is the backtracking solver?
For standard published Sudoku puzzles (easy to expert), backtracking typically solves in milliseconds. For puzzles with very few clues, it can take longer because more backtracking is needed.
Can the solver handle invalid puzzles?
Yes. If a puzzle has no solution (e.g., duplicate digits in a row), the solver detects this and displays an error message. If a puzzle has multiple solutions, the solver returns the first one it finds.
Does this tool also generate Sudoku puzzles?
No. This tool only solves puzzles. For puzzle generation, use the Sudoku Generator and Solver tool on this site, which can generate puzzles at various difficulty levels.
Conclusion
The Sudoku solver provides instant solutions to any valid 9x9 Sudoku puzzle using a backtracking algorithm. Whether you are stuck on a newspaper puzzle or want to verify your own solution, this tool handles it entirely in your browser. For generating new puzzles, use the Sudoku Generator and Solver tool on this site.