checkNurikabefunction
Checks island areas and separation, the connected sea, and the ban on 2×2 sea blocks.
Import it
import { checkNurikabe } from "@johnmorrisdotca/kazu/nurikabe";
Also exported from: @johnmorrisdotca/kazu
Definition
function checkNurikabe(board: NurikabeBoard, sea: readonly boolean[]): { ok: boolean; errors: readonly number[]; }
Parameters
| Name | Type | Description |
|---|---|---|
board | NurikabeBoard | The valid native board with its printed clues and dimensions. |
sea | readonly boolean[] | The current sea-cell flags in row-major order. |
Returns
{ ok: boolean; errors: readonly number[]; }
Checks island areas and separation, the connected sea, and the ban on 2×2 sea blocks.
Examples
import type { NurikabeBoard, NurikabePuzzle } from "@johnmorrisdotca/kazu/nurikabe";
import { checkNurikabe } from "@johnmorrisdotca/kazu/nurikabe";
const nurikabeBoard: NurikabeBoard = {"size":5,"clues":[1,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,2,0,0,3,0,0]};
const nurikabeSolution: NurikabePuzzle["solution"] = [false,true,true,true,false,true,true,false,false,false,true,false,false,true,true,true,true,true,true,false,false,false,false,true,false];
console.log(checkNurikabe(nurikabeBoard,nurikabeSolution));{ ok: true, errors: [] }What it prints (run when this page was built)