Compare commits

..

1 Commits

Author SHA1 Message Date
99b859174f Log the number of dancing link updates 2021-03-03 18:04:28 -07:00

View File

@ -141,7 +141,7 @@ export class SudokuMath {
return [...firstRow, ...Array(this.values2 - this.values).fill(0)];
}
generateComplete(): [number[], number] {
generateComplete() {
const result = this._baseBoard();
const [header] = this.getDLXHeader(result, true);
@ -157,15 +157,16 @@ export class SudokuMath {
const dlx = new DLX(header, callback);
dlx.search();
return [result, dlx.updates];
return result;
}
generate(clues: number, attempts = Infinity, totalTime = Infinity) {
const [completed, updates] = this.generateComplete();
const completed = this.generateComplete();
const [header, dlxRows] = this.getDLXHeader(); // complete header - no candidates removed
let solutions = 0;
let updates = 0;
const dlx = new DLX(header, () => ++solutions >= 2);
const candidates: DNode[][] = Array.from(Array(this.values2), () =>