js-sudoku-generator

0.0.3 • Public • Published

js-sudoku-generator

Javascript Sudoku sheet generator

Dependencies

  • node js (https://nodejs.org/)

Installation

  • install via npm:
npm install js-sudoku-generator --save

Build instructions

  • install dependencies via: npm install
  • build with webpack via: webpack --config webpack.prod.js
  • Once library is built, in the "dist" folder, you will find both node (dist/js-sudoku-generator.js) / web (dist/js-sudoku-generator.web.js) version of the lib.

inclusion

NodeJS

const 
    SudokuGenerator = require("js-sudoku-generator").SudokuGenerator;

Web

<script src="./node_modules/js-sudoku-generator/dist/js-sudoku-generator.web.js"></script>

code examples

// generate sudoku solution boards, single argument is the number of boards
SudokuGenerator.generate(2);
 
// get difficulty sheets 
let l_oFirstBoard = SudokuGenerator.generatedBoards[0];
 
// get sheet signature (for loading)
console.log(l_oFirstBoard.signature);
 
// load saved board 
let l_oLoadedBoard = SudokuGenerator.loadBoard(l_oFirstBoard.signature);
 
// get hard difficulty sheet
let l_aHardSheet = l_oFirstBoard.getSheet(2);
 
// get medium difficulty sheet
let l_aMediumSheet = l_oFirstBoard.getSheet(1);
 
// get easy difficulty sheet
let l_aEasySheet = l_oFirstBoard.getSheet(0);
 
// pretty print solution to console
l_oFirstBoard.prettyPrint();
 
// pretty print sheet
l_oFirstBoard.prettyPrint(l_aEasySheet);

Readme

Keywords

Package Sidebar

Install

npm i js-sudoku-generator

Weekly Downloads

8

Version

0.0.3

License

ISC

Unpacked Size

62.3 kB

Total Files

11

Last publish

Collaborators

  • boggan42