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

sudoku-solver-engine

v1.0.3

Published

Sudoku solver engine

Downloads

3

Readme

Features

  • Solve any valid sudoku.
  • Detect invalid sudokus.
  • 5 preset of sudokus.
  • Logs are directly connected to the program status.

How to use this ?

installation:

cd into your project and execute:

npm i sudoku-solver-engine
//or with yarn
yarn add sudoku-solver-engine

Intro:

This is a node_module that can solve a sudoku step by step and produce a full log of how the code solve the problem.

This package is meant yo be use both server-side and client-side. (files are builded with babel)

But if you are using this client-side, make sure to use a front-end framework ( angular / react / vue / etc ) to take advantage of the webpack config.

The best aproach for a "sudoku solver app" would be to put the engine in the general store manager (redux / vueX)

But you can import the diffrent objects in on component and do all the work in the component.

Classes:

sudoku data:

import {grid, gridClear, grid3, grid4, grid5, grid6} from 'sudoku-solver-engine'

This is all the available sudokus. Those grid are 9x9 matices. gridClear is an empty 9x9 matrix. grid2 is not available beacause it's a damned sudoku...

Sudoku class:

This class is meant perform get / set / display / test of a sudoku.

import {Sudoku} from 'sudoku-solver-engine'

Creation:

const mySudoku = new Sudoku(grid) // use any grid that you want

ToolBox class:

This is just a set of helper. (I will explain why in the next section)

import {ToolBox} from 'sudoku-solver-engine'

Engine class:

This class is meant to solve a sudoku

import {Engine} from 'sudoku-solver-engine'

Creation:

myEngine = new Engine(mySudoku, myTooBox)

I know, this: new Engine(mySudoku, myTooBox) is not efficient. But this code was produce to explain to my students the concept of oop

Example:

  • create a new directory.
  • cd inside
  • execute yarn init / npm init
  • install the sudoku-solver-engine
  • create a testSudoku.js file and write inside:
const {Engine, ToolBox, Sudoku, grid} = require('sudoku-solver-engine')
// or in a front-end framework: import {Engine, ToolBox, Sudoku, grid} from 'sudoku-solver-engine'
const myTooBox = new ToolBox()
const mySudoku = new Sudoku(grid)

mySudoku.displayGrid("Initial sudoku")
const myEngine = new Engine(mySudoku, myTooBox)
myEngine.solveAll()

console.log("testSolveAll")
console.log(myEngine.logs.length)
console.log(myEngine.logs)
mySudoku.displayGrid("Finished sudoku")
  • execute: node testSudoku.js
  • enjoy :) !

The sudoku grid is the same everywhere. They all share the same data !

Important

Some Sudokus cannot be solved with this algorithm. Those Sudokus need an assumption to continue the resolution.

But the algorithm is able to detect when an assumption needs to be made, so, you could work on the version 2 of this code that would be able to solve those Sudokus ;)!

Technical stack

  • JS ES6
  • Babel
  • Npm
  • Git
  • A lot of patience :p

About

Npm module made from scratch by me, for you, with <3. I used this code to do this in react.