1.0.4 • Published 4 years ago

@bbunderson/sudoku-solver v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

A simple hueristic Sudoku solver

const sudoku = require('@bbunderson/sudoku-solver');

const TEST_BOARD = [
	0, 0, 0, 2, 6, 0, 7, 0, 1,
	6, 8, 0, 0, 7, 0, 0, 9, 0,
	1, 9, 0, 0, 0, 4, 5, 0, 0,
	8, 2, 0, 1, 0, 0, 0, 4, 0,
	0, 0, 4, 6, 0, 2, 9, 0, 0,
	0, 5, 0, 0, 0, 3, 0, 2, 8,
	0, 0, 9, 3, 0, 0, 0, 7, 4,
	0, 4, 0, 0, 5, 0, 0, 3, 6,
	7, 0, 3, 0, 1, 8, 0, 0, 0
];

var results;

results = sudoku.solve_grid(TEST_BOARD);
if (results.solved) {
    console.log('I solved the puzzle!', results.solution.toString());
} else {
    console.log('I give up!');
}
const sudoku = require('@bbunderson/sudoku-solver');

results = sudoku.solve_string('000260701680070090190004500820100040004602900050003028009300074040050036703018000');
if (results.solved) {
    console.log('I solved the puzzle!', results.solution);
} else {
    console.log('I give up!');
}

PROTIP Set the environment variable SUDOKU_DEBUG=true to output each step of the solver process.

Installation

This is a Node.js module available through the npm registry.

Before installing, download and install Node.js. Node.js 0.10 or higher is required.

Installation is done using the npm install command:

$ npm install @bbunderson/sudoku-solver

Features

  • Uses a simple bookmarking hueristic
  • Uses a back-tracking algorithm if hueristic methods fail
  • Optionally shows each step of the process

Sudoku

People

The current lead maintainer is Bryant Bunderson

License

MIT

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago