Compare commits
1 Commits
99b859174f
...
e8f9c2f15d
Author | SHA1 | Date | |
---|---|---|---|
e8f9c2f15d |
@ -141,7 +141,7 @@ export class SudokuMath {
|
|||||||
return [...firstRow, ...Array(this.values2 - this.values).fill(0)];
|
return [...firstRow, ...Array(this.values2 - this.values).fill(0)];
|
||||||
}
|
}
|
||||||
|
|
||||||
generateComplete() {
|
generateComplete(): [number[], number] {
|
||||||
const result = this._baseBoard();
|
const result = this._baseBoard();
|
||||||
const [header] = this.getDLXHeader(result, true);
|
const [header] = this.getDLXHeader(result, true);
|
||||||
|
|
||||||
@ -157,16 +157,15 @@ export class SudokuMath {
|
|||||||
const dlx = new DLX(header, callback);
|
const dlx = new DLX(header, callback);
|
||||||
|
|
||||||
dlx.search();
|
dlx.search();
|
||||||
return result;
|
return [result, dlx.updates];
|
||||||
}
|
}
|
||||||
|
|
||||||
generate(clues: number, attempts = Infinity, totalTime = Infinity) {
|
generate(clues: number, attempts = Infinity, totalTime = Infinity) {
|
||||||
const completed = this.generateComplete();
|
const [completed, updates] = this.generateComplete();
|
||||||
|
|
||||||
const [header, dlxRows] = this.getDLXHeader(); // complete header - no candidates removed
|
const [header, dlxRows] = this.getDLXHeader(); // complete header - no candidates removed
|
||||||
|
|
||||||
let solutions = 0;
|
let solutions = 0;
|
||||||
let updates = 0;
|
|
||||||
const dlx = new DLX(header, () => ++solutions >= 2);
|
const dlx = new DLX(header, () => ++solutions >= 2);
|
||||||
|
|
||||||
const candidates: DNode[][] = Array.from(Array(this.values2), () =>
|
const candidates: DNode[][] = Array.from(Array(this.values2), () =>
|
||||||
|
Loading…
Reference in New Issue
Block a user