diff --git a/src/visualizeValues.ts b/src/visualizeValues.ts new file mode 100644 index 0000000..a8478f6 --- /dev/null +++ b/src/visualizeValues.ts @@ -0,0 +1,26 @@ +import { getXYW } from "./util"; + +export function visualizeValues(values: number[]): void { + const sudoku: (number | null)[][] = Array.from({ length: 9 }, () => Array.from({ length: 9 }, () => null)); + for (const value of values) { + const { x, y, w } = getXYW(value); + sudoku[y - 1]![x - 1] = w; + } + + for (let y = 9; y > 0; y--) { + if (y % 3 === 0) { + console.log("+---------+---------+---------+"); + } + + for (let x = 0; x < 9; x++) { + if (x % 3 === 0) { + process.stdout.write("|"); + } + process.stdout.write(sudoku[y - 1]![x] === null ? " " : " " + sudoku[y - 1]![x]!.toString() + " "); + } + + console.log("|"); + } + + console.log("+---------+---------+---------+"); +}