Sudoku
Generate and solve Sudokus
Getting Started
Quick guide on how to use the package
Create your Sudoku Game
Install the NPM package
npm install game-sudoku
Import Sudoku to your project and create a new Game (ES6 module syntax):
;;
... or using CommonJS syntax:
const { Sudoku } = require('game-sudoku')
const sudoku = new Sudoku()
Use your own template (see examples below):
; ; ; sudoku.generatehardLayout;
Play your Sudoku
Get the Board:
;
... or print it on the command line:
sudoku.grid.print;// · · · · · · · · ·// · · · · · 3 · 8 5// · · 1 · 2 · · · ·// · · · 5 · 7 · · ·// · · 4 · · · 1 · ·// · 9 · · · · · · ·// 5 · · · · · · 7 3// · · 2 · 1 · · · ·// · · · · 4 · · · 9
Write it down digits:
;;; sudoku.writeCellrow, column, digit; sudoku.grid.print;// · · · · · · · · ·// · · · 1 · 3 · 8 5// · · 1 · 2 · · · ·// · · · 5 · 7 · · ·// · · 4 · · · 1 · ·// · 9 · · · · · · ·// 5 · · · · · · 7 3// · · 2 · 1 · · · ·// · · · · 4 · · · 9
... or erase them:
;; sudoku.eraseCellrow, column; sudoku.grid.print;// · · · · · · · · ·// · · · · · 3 · 8 5// · · 1 · 2 · · · ·// · · · 5 · 7 · · ·// · · 4 · · · 1 · ·// · 9 · · · · · · ·// 5 · · · · · · 7 3// · · 2 · 1 · · · ·// · · · · 4 · · · 9
Solve the Game
You can get Hints:
sudoku.solve"one".grid.print;// · · · · · · · · ·// · · · 1 · 3 · 8 5// · · 1 · 2 · · · ·// · · · 5 · 7 · · ·// · · 4 · · · 1 · ·// · 9 · · · · · · ·// 5 · · · · · · 7 3// · · 2 · 1 · · · ·// · · · · 4 · · · 9
Or solve the entire game:
sudoku.solve"all".grid.print;// 9 8 7 6 5 4 3 2 1// 2 4 6 1 7 3 9 8 5// 3 5 1 9 2 8 7 4 6// 1 2 8 5 3 7 6 9 4// 6 3 4 8 9 2 1 5 7// 7 9 5 4 6 1 8 3 2// 5 1 9 2 8 6 4 7 3// 4 7 2 3 1 9 5 6 8// 8 6 3 7 4 5 2 1 9
Reset the Game
Get back to the initial state:
sudoku.reset.grid.print;// · · · · · · · · ·// · · · · · 3 · 8 5// · · 1 · 2 · · · ·// · · · 5 · 7 · · ·// · · 4 · · · 1 · ·// · 9 · · · · · · ·// 5 · · · · · · 7 3// · · 2 · 1 · · · ·// · · · · 4 · · · 9
Coming next
This is the list of upcoming features:
- v1 - Sudoku Solver => Increase test coverage to stabilise and release
- v2 - Sudoku Generator => Generate games without a given layout
- v3 - Deliver the ability to write candidates/marks in the cell