From 4e6cdab9eeacb63ee548dd76df6dc8c617cbc74c Mon Sep 17 00:00:00 2001 From: Matt Low Date: Thu, 4 Mar 2021 21:35:25 -0700 Subject: [PATCH] Return blank array when requested clues == 0 --- src/sudoku/math.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sudoku/math.ts b/src/sudoku/math.ts index 6e32b87..fdfe125 100644 --- a/src/sudoku/math.ts +++ b/src/sudoku/math.ts @@ -158,6 +158,10 @@ export class SudokuMath { } generate(clues: number, attempts = Infinity, totalTime = Infinity) { + if (clues === 0) { + return Array(this.values2).fill(0); + } + let [completed, updates] = this.generateComplete(); const [header, dlxRows] = this.getDLXHeader(); // complete header - no candidates removed