sudoky-lib
v0.0.5
Published
Simple Sudoku Backtracking Algorithm. Enjoy :)
Downloads
4
Readme
SudokyLib
Simple Sudoku Backtracking Algorithm.
Enjoy :)
Module Import
import {SudokyLibModule} from 'sudoky-lib';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AppRoutingModule,
SudokyLibModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Service Import
import {SudokyLibService} from 'sudoky-lib';
export class AppComponent implements OnInit{
sudoky: SudokyLibService;
constructor() {
this.sudoky = new SudokyLibService(false);
}
}
Constructor
this.sudoky = new SudokyLibService(false);
- param: showLog (boolean)
Methods
GenerateBoard
this.sudoky.generateBoard();
RemoveClues
this.sudoky.removeClues();
GetSolvedValue
const solvedValue: number = this.sudoky.getSolvedValue(emptyCell);
Print Boards
Print unresolved board
this.sudoky.printBoard();
Print solved board
this.sudoky.printSolvedBoard();
Flow
Code Example
constructor() {
this.sudoky = new SudokyLibService(false);
}
onGenerateBoardClick(): void {
// Clear the previous board value statement.
this.sudoky.reset();
this.sudoky.generateBoard();
this.sudoky.removeClues();
console.log(this.sudoky.printBoard());
const emptyCell: Cell = this.sudoky.findEmpty();
const solvedValue: number = this.sudoky.getSolvedValue(emptyCell);
console.log(`Solved value ${solvedValue} at position (x: ${emptyCell.row},y: ${emptyCell.column})`);
console.log(this.sudoky.printSolvedBoard());
}