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

@hackettyam/sudoku-tools

v1.0.0

Published

A lightweight, zero-dependency TypeScript library for Sudoku puzzle generation, manipulation, and utilities.

Readme

🧩 @hackettyam/sudoku-tools

A lightweight, zero-dependency TypeScript library for Sudoku puzzle generation, manipulation, and utilities. This library provides pure logic functions without any UI or framework dependencies, making it suitable for any JavaScript/TypeScript project.

TypeScript License Coverage

✨ Features

  • 🔷 Pure TypeScript - Full type safety with comprehensive type definitions
  • 📦 Zero Dependencies - No external runtime dependencies
  • 🎯 Framework Agnostic - Works with any JavaScript framework or vanilla JS
  • 🧱 Modular Design - Import only what you need
  • 100% Test Coverage - Thoroughly tested and reliable

📦 Installation

📥 Package Manager

Install using your preferred package manager:

# npm
npm install @hackettyam/sudoku-tools

# yarn
yarn add @hackettyam/sudoku-tools

# pnpm
pnpm add @hackettyam/sudoku-tools

🔗 Path Alias (Monorepo)

If using as a local package in a monorepo, add the path alias to your tsconfig.json:

{
  "compilerOptions": {
    "paths": {
      "@hackettyam/sudoku-tools": ["./libs/@hackettyam/sudoku-tools/src"]
    }
  }
}

🚀 Quick Start

Create your first Sudoku puzzle in seconds:

import { createSudoku, Difficulty } from '@hackettyam/sudoku-tools'

// 1️⃣ Create a puzzle
const puzzle = createSudoku(Difficulty.Normal)

// 2️⃣ Play the game
puzzle.setCell(0, 0, 5)           // ✏️ Set a cell value
const hint = puzzle.getHint()     // 💡 Get help when stuck
puzzle.getCandidates(0, 0)        // 📋 See valid options

// 3️⃣ Track progress
console.log(puzzle.getProgress()) // 📊 { progress: 45, validCells: 35, ... }
console.log(puzzle.isSolved())    // 🏆 Check if solved!

📖 Documentation

Explore the complete documentation in docs/:

| Section | Description | |---------|-------------| | 🚀 Getting Started | Installation, setup, and first puzzle | | 🧩 SudokuPuzzle | Main puzzle class - play, hint, validate | | 🛠️ Utilities | Helper functions for everything else | | 📦 Models & Types | TypeScript types and interfaces | | 🔢 Constants | Grid and difficulty constants | | 💡 Examples | Real-world usage patterns | | 🔄 Transformations | Rotate, mirror, shuffle boards | | ✅ Validation | Check moves and board states |

🎮 API Overview

🧩 Creating Puzzles

import { createSudoku, Difficulty } from '@hackettyam/sudoku-tools'

const puzzle = createSudoku(Difficulty.Hard)

🧩 SudokuPuzzle Methods

| Method | Description | |--------|-------------| | ✏️ setCell(row, col, value) | Place a number in a cell | | 🗑️ clearCell(row, col) | Erase a cell | | 📋 getCandidates(row, col) | Get valid options for a cell | | 💡 getHint() | Get help when stuck | | 📊 getProgress() | See completion stats | | 🛡️ isValidMove(row, col, value) | Check before placing | | ✅ isComplete() | All cells filled? | | 🏆 isSolved() | Puzzle solved correctly? | | 🔄 reset(randomize?) | Start over |

🎚️ Difficulty Levels

Choose the right challenge:

| Level | Hints | Empty Cells | Best For | |-------|-------|-------------|----------| | 🟢 Novice | 50 | 31 | Beginners | | 🟡 Easy | 40 | 41 | Casual play | | 🟠 Normal | 35 | 46 | Regular players | | 🔴 Hard | 30 | 51 | Challenge seekers | | ⚫ Expert | 20 | 61 | Sudoku masters |

🔧 Utilities

Powerful helper functions for advanced use cases:

import {
  // 🎲 Board manipulation
  cloneBoard,          // Deep copy a board
  setCellValue,        // Immutably set a cell
  clearCell,           // Immutably clear a cell

  // 🧠 Solving
  solvePuzzle,         // Solve any valid puzzle
  hasUniqueSolution,   // Verify single solution

  // ✅ Validation
  isValidPuzzle,       // Check entire board
  isValidRow,          // Check specific row
  isValidColumn,       // Check specific column
  isValidBox,          // Check 3x3 box

  // 🔄 Transformations
  rotateBoard,         // Rotate 90° clockwise
  mirrorBoard,         // Flip horizontally/vertically
  randomizeBoard,      // Shuffle for variety

  // 💾 Serialization
  serializeBoard,      // Board → string (save)
  deserializeBoard,    // String → board (load)

  // 📊 Analysis
  getDifficulty,       // Estimate puzzle difficulty
  getCandidates,       // Valid values for a cell
  getHint,             // Find next move
} from '@hackettyam/sudoku-tools'

📝 TypeScript Support

Full type safety out of the box:

import type {
  BoardType,              // 9x9 number grid
  CellValue,              // 0-9 cell value
  DifficultyType,         // Difficulty string union
  HintResult,             // { row, col, value }
  SudokuPuzzleStatistics, // Progress tracking
} from '@hackettyam/sudoku-tools'

📄 License

MIT © hackettyam


Happy puzzling! 🧩✨