Log the number of dancing link updates

This commit is contained in:
Matt Low 2021-03-03 18:04:28 -07:00
parent 058dc13c1c
commit 99b859174f

View File

@ -166,6 +166,7 @@ export class SudokuMath {
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), () =>
@ -183,6 +184,7 @@ export class SudokuMath {
const hasOneSolution = () => {
solutions = 0;
dlx.search();
updates += dlx.updates;
return solutions === 1;
};
@ -248,6 +250,7 @@ export class SudokuMath {
removed.forEach((index) => {
completed[index] = 0;
});
console.log("DLX updates:", updates);
return completed;
}