Reference · Number-puzzle engines
conflictsOffunction
THE CELLS THAT BREAK A RULE RIGHT NOW, read from the rules alone: no answer is needed, so it works on any puzzle, and it names a mistake the moment it is made rather than when it is checked.
values is the whole grid as it stands: the printed numbers and what has been written, row-major,
0 for empty. A cell is in conflict when it shares a row, a column, a box, a region, a diagonal or a
cage with a cell holding the same number; when a cage is full and does not add to its sum, or already
adds to more; when a more-than mark between two filled cells is not true; or when the cells from a
Towers clue show more towers than the clue says (or, once the line is full, any other number).
An empty cell is never in conflict, and a grid with no conflict is not thereby right: it may
simply not be finished.
Import it
import { conflictsOf } from "@johnmorrisdotca/kazu";
Definition
function conflictsOf(givens: KazuGivens, values: readonly number[]): number[]
Parameters
| Name | Type | Description |
|---|---|---|
givens | KazuGivens | The original native printed-clue code. |
values | readonly number[] | Replacement text/numbers or row-major entries specified by this signature. |
Returns
number[]
THE CELLS THAT BREAK A RULE RIGHT NOW, read from the rules alone: no answer is needed, so it works on any puzzle, and it names a mistake the moment it is made rather than when it is checked.
Examples
import type { KazuPuzzle } from "@johnmorrisdotca/kazu";
import { conflictsOf, decodeCells, readGivens } from "@johnmorrisdotca/kazu";
const puzzle: KazuPuzzle = {"kind":"number-place","size":4,"level":"easy","seed":42,"givens":"14..2..1412.3..4","solution":"1432234141233214"};
const kind = puzzle.kind;
const size = puzzle.size;
const givens = puzzle.givens;
const answer = puzzle.solution;
const printed = readGivens(kind,size,givens)!;
const solution = decodeCells(answer,size)!;
console.log(conflictsOf(printed,solution));[]What it prints (run when this page was built)