0.0.5 • Published 3 years ago

sudoky-lib v0.0.5

Weekly downloads
20
License
-
Repository
-
Last release
3 years ago

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());
  }
0.0.5

3 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago