npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fast-sudoku-solver

v1.1.16

Published

A fast Sudoku solver written in TypeScript.

Downloads

177

Readme

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