js-sudoku
v1.0.10
Published
sudoku.js ts js npm
Downloads
23
Maintainers
Readme
sudoku
Live Demo
Usage
In Browser
Locally…
<script src="sudoku.js"></script>
… or Directly from CDN. In which case you don't even need to install.
<script src="https://unpkg.com/js-sudoku@latest/dist/index.js"></script>
// generate sudokuList to show
const list = sudoku.gen({ gzip: false, mask: false, level: sudoku.Level.LOW });
// verify users result
const isValid = sudoku.verify(list);
Install
npm install js-sudoku
# or
yarn add js-sudoku
es model...
import { gen, Level } from 'js-sudoku';
const list = gen({ gzip: false, mask: false, level: Level.LOW });
...node
const { gen, Level } = require('js-sudoku');
const list = gen({ gzip: false, mask: false, level: Level.LOW });
type
enum Level {
LOW,
MIDDLE,
HIGH
}
type sudokuList = number[][];
interface genOptions {
mask?: boolean;
gzip?: boolean;
level?: Level;
}
Methods
gen: (opt: genOptions) => sudokuList | string;
| params | type | description | | :--- | :--- | :--- | | mask | boolean | random position fill 0 | | gzip | boolean | gzip result | | level | Level | degree of difficulty working when mask |
verify: (list: sudokuList) => boolean;
| params | type | description | | :--- | :--- | :--- | | list | sudokuList | none |