# fast-sudoku-solver

> A fast Sudoku solver written in TypeScript.

Latest version **4.0.0** (published 2026-10-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install fast-sudoku-solver
pnpm add fast-sudoku-solver
yarn add fast-sudoku-solver
bun add fast-sudoku-solver
```

## Health

**Score 65/100 (B)** — status: active.

Positive: esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-10-18 |
| First published | 2022-09-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 0 |
| Unpacked size | 32.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | luthium |
| Maintainers | luthium |
| Keywords | sudoku, puzzle, solver |

## Links

- npm: https://www.npmjs.com/package/fast-sudoku-solver
- Repository: https://github.com/luth1um/sudoku-solver-typescript
- Homepage: https://github.com/luth1um/sudoku-solver-typescript#readme
- Issues: https://github.com/luth1um/sudoku-solver-typescript/issues
- npm.io page: https://npm.io/package/fast-sudoku-solver

## Recent versions

- 4.0.0 (latest) — 2026-10-18
- 3.0.4 — 2026-09-03
- 3.0.3 — 2026-05-14
- 3.0.2 — 2026-03-29
- 3.0.1 — 2026-03-15
- 3.0.0 — 2026-01-01
- 2.0.0 — 2025-11-23
- 1.1.24 — 2025-11-22
- 1.1.23 — 2025-11-09
- 1.1.22 — 2025-10-15
- 1.1.21 — 2025-09-12
- 1.1.20 — 2025-08-28
- 1.1.19 — 2025-06-15
- 1.1.18 — 2025-03-29
- 1.1.17 — 2025-01-02
- … 21 more at https://npm.io/package/fast-sudoku-solver/versions

## README

# 🤔 Sudoku Solver

A [Sudoku](https://en.wikipedia.org/wiki/Sudoku) solver written in TypeScript. The solver applies optimized [backtracking](https://en.wikipedia.org/wiki/Backtracking) for solving puzzles. If you want to see the solver in action, you can visit [this website](https://luth1um.github.io/sudoku-solver-angular/).

The solver expects as argument a 9x9 `number` array where an entry is either an integer between `1` and `9` (in case the entry is known), or `-1` (in case the entry is unknown and needs to be calculated by the solver).

# 🚀 Functions

Currently, the solver provides the following functions:

- `solveSudoku(sudoku: number[][])`: Solves a Sudoku puzzle. The function returns an array `[solvable: boolean, solution: number[][]]`. Here, `solvable` indicates whether the Sudoku puzzle is solvable or not, and `solution` is a valid solution for the Sudoku puzzle (if the puzzle is solvable).
- `nextNumber(sudoku: number[][])`: Calculates the next number for a Sudoku puzzle. The function returns whether the puzzle _isSolvable_, and it returns the _row_, the _column_, and the _entry_ itself for the next number. In particular, the function returns the entry for the field with the fewest number of possible entries. For instance, if there is a field with 7 possible entries and another field with only 2 possible entries, a correct entry for the latter is returned. **NOTE:** If the Sudoku puzzle is already completely solved, this function returns value _-1_ for _row_, _column_, and _entry_.

# 🔍 Input Validation

Note, that the solver currently does not validate Sudoku puzzles. Instead, the solver expects the following properties for inputs:

- The input is a 9x9 `number[][]` array where each entry is an integer between `1` and `9`, or `-1` (see above).
- Each row contains every value between `1` and `9` **at most** once.
- Each column contains every value between `1` and `9` **at most** once.
- Each 3x3 box contains every value between `1` and `9` **at most** once.

# 🔗 Links

- Sudoku solver on [GitHub](https://github.com/luth1um/sudoku-solver-typescript)
- Sudoku solver package on [npm](https://www.npmjs.com/package/fast-sudoku-solver)

---
_Source: https://npm.io/package/fast-sudoku-solver · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
