feat: expand sudoku analysis and interoperability

This commit is contained in:
2026-08-30 23:21:56 +02:00
parent 4a9869baa0
commit 8ca9300ab3
73 changed files with 12482 additions and 384 deletions
+30 -1
View File
@@ -35,7 +35,30 @@ describe("Sudoku Tools document format", () => {
centerMarks: Array.from({ length: 81 }, () => [7, 4]),
colors: Array.from({ length: 81 }, (_, index) => index % 9),
elapsedMs: 12_345,
constraints: [{ type: "killer-cage", cells: [0, 1], sum: 3 }],
constraints: [
{ type: "killer-cage", cells: [0, 1], sum: 3 },
{
type: "x-sum",
side: "top",
index: 8,
sum: 1111,
negated: true,
},
{
type: "skyscraper",
side: "left",
index: 4,
count: 898,
negated: true,
},
{
type: "quadruple",
cells: [0, 1, 9, 10],
digits: [1, 3, 8],
negated: true,
},
{ type: "maximum", cell: 10, negated: true },
],
};
const parsed = parseSudokuDocument(serializeSudokuDocument(source));
expect(parsed).toEqual({
@@ -59,6 +82,12 @@ describe("Sudoku Tools document format", () => {
values: [2, ...Array<number>(15).fill(0)],
}),
).toThrow(/preserve its given digit/u);
expect(() =>
normalizeSudokuDocument({
...document(Array(81).fill(0)),
constraints: [{ type: "quadruple", cells: [0], digits: [1, 2] }],
}),
).toThrow(/no more digits than clue cells/u);
});
it("round-trips compact share hashes", () => {