Compare commits
1 Commits
e8f9c2f15d
...
99b859174f
Author | SHA1 | Date | |
---|---|---|---|
99b859174f |
@ -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(): [number[], number] {
|
generateComplete() {
|
||||||
const result = this._baseBoard();
|
const result = this._baseBoard();
|
||||||
const [header] = this.getDLXHeader(result, true);
|
const [header] = this.getDLXHeader(result, true);
|
||||||
|
|
||||||
@ -157,15 +157,16 @@ export class SudokuMath {
|
|||||||
const dlx = new DLX(header, callback);
|
const dlx = new DLX(header, callback);
|
||||||
|
|
||||||
dlx.search();
|
dlx.search();
|
||||||
return [result, dlx.updates];
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
generate(clues: number, attempts = Infinity, totalTime = Infinity) {
|
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
|
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