[HAI] isValidSudoku WIP

This commit is contained in:
2024-11-27 21:57:49 +03:00
parent 6c6bb69160
commit 9e79211174
4 changed files with 147 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import { describe, it, expect } from "vitest";
import { isValidSudoku } from "./isValidSudoku.ts";
describe("isValidSudoku", () => {
it("true case", () => {
const board =
[["5", "3", ".", ".", "7", ".", ".", ".", "."]
, ["6", ".", ".", "1", "9", "5", ".", ".", "."]
, [".", "9", "8", ".", ".", ".", ".", "6", "."]
, ["8", ".", ".", ".", "6", ".", ".", ".", "3"]
, ["4", ".", ".", "8", ".", "3", ".", ".", "1"]
, ["7", ".", ".", ".", "2", ".", ".", ".", "6"]
, [".", "6", ".", ".", ".", ".", "2", "8", "."]
, [".", ".", ".", "4", "1", "9", ".", ".", "5"]
, [".", ".", ".", ".", "8", ".", ".", "7", "9"]];
expect(isValidSudoku(board)).toBeTruthy();
});
it("false case", () => {
const board =
[["8", "3", ".", ".", "7", ".", ".", ".", "."]
, ["6", ".", ".", "1", "9", "5", ".", ".", "."]
, [".", "9", "8", ".", ".", ".", ".", "6", "."]
, ["8", ".", ".", ".", "6", ".", ".", ".", "3"]
, ["4", ".", ".", "8", ".", "3", ".", ".", "1"]
, ["7", ".", ".", ".", "2", ".", ".", ".", "6"]
, [".", "6", ".", ".", ".", ".", "2", "8", "."]
, [".", ".", ".", "4", "1", "9", ".", ".", "5"]
, [".", ".", ".", ".", "8", ".", ".", "7", "9"]]
expect(isValidSudoku(board)).toBeFalsy();
});
});