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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@wsabol/sudoku-solver

v0.1.10

Published

TypeScript Sudoku solver module with solve, next move, describe, and validate APIs.

Readme

Sudoku Solver (Node Module)

TypeScript module for Sudoku solve, next move, describe, and validate operations.

Install

npm install

Build

npm run build

Build output is written to dist/.

Usage

import Sudoku from "sudoku-solver";

const board =
    "000010080302607000070000003080070500004000600003050010200000050000705108060040000";

const solved = Sudoku.solve(board);
console.log(solved.isValid); // true
console.log(solved.board);   // number[][]

const next = Sudoku.nextMove(board);
console.log(next.status);  // "In progress"
console.log(next.message); // same as next.move?.message when a move exists, e.g. "Place 4 in r1c3 (Naked Single)"
if (next.move?.type === "placement") {
    console.log(next.move.row, next.move.col, next.move.value, next.move.reasoning);
} else if (next.move?.type === "elimination") {
    console.log(next.move.eliminations); // [{ row, col, value }, ...]
    // multi-value eliminations: message uses sorted set like "2/5/7" in the Eliminate … part
}

const check = Sudoku.validate(board);
console.log(check.isValid);  // true/false
console.log(check.reasons);  // ValidationReason[]

const info = Sudoku.describe(board);
console.log(info.difficulty); // "Easy" | "Medium" | "Hard" | "Diabolical" | "Impossible"
console.log(info.solutions);  // 0 | 1

API

Sudoku.solve(boardInput)

Accepts string | number[][].

Returns:

{
    isValid: boolean;
    board: number[][];
}

isValid is false when the board is structurally invalid or has no solution.

Sudoku.nextMove(boardInput)

Accepts string | number[][].

Returns:

{
    status: "Complete" | "In progress" | "Invalid";
    move: PlacementMove | EliminationMove | null;
    message: string;
}

move is a discriminated union:

// digit placement
{
    type: "placement";
    row: number;
    col: number;
    value: number;
    algorithm: Algorithm;
    message: string;
    reasoning: string;
}

// candidate elimination (e.g. Pointing Pair or Pointing Triple)
{
    type: "elimination";
    eliminations: Array<{ row: number; col: number; value: number }>;
    algorithm: Algorithm;
    message: string;
    reasoning: string;
}

Notes:

  • move is null when the board is complete or invalid.
  • move.type must be checked before accessing placement-specific fields (row, col, value).
  • message: placement uses 1-based coords in text, e.g. Place 4 in r1c3 (Naked Single). Elimination counts distinct cells and names a common house when all targets share one row, column, or 3×3 box, e.g. Eliminate 5 from 2 cells in row 4 (Pointing Pair) or Eliminate 2/7/9 from 3 cells in box 7 (Naked Triple); several distinct values use {2/5/7} in the digit part.
  • reasoning: one sentence describing why the move is sound (technique-specific).
  • Top-level message matches move.message when move is non-null.

Sudoku.validate(boardInput)

Accepts string | number[][].

Returns:

{
    isValid: boolean;
    message: string;
    reasons: ValidationReason[];
}

Sudoku.describe(boardInput)

Accepts string | number[][].

Returns:

{
    isValid: boolean;
    isComplete: boolean;
    message: string;
    difficulty: "Easy" | "Medium" | "Hard" | "Diabolical" | "Impossible" | null;
    solutions: number;
}

difficulty is derived from empty cell count when the board is valid; null when isValid === false. solutions is 0 when the board is invalid/unsolvable, 1 when a unique solution exists.

Development

npm test
npm run typecheck