1.1.16 • Published 1 month ago

fast-sudoku-solver v1.1.16

Weekly downloads
-
License
MIT
Repository
github
Last release
1 month ago

Build

🤔 Sudoku Solver

A Sudoku solver written in TypeScript. The solver applies optimized backtracking for solving puzzles. If you want to see the solver in action, you can visit this website.

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
  • Sudoku solver package on npm
1.1.16

1 month ago

1.1.15

3 months ago

1.1.14

5 months ago

1.1.13

7 months ago

1.1.12

9 months ago

1.1.11

11 months ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.1

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago