Skip to the content

Kazu数

Generate checked Sudoku and logic puzzles, read native rules and hints, and draw or embed playable boards.

Kazu is the Japanese word 数 for number. About the name

Contents

Reference · Playable number grid

KazuMountOptionstype

The puzzle, optional solution/progress, assistance, controls and event callbacks for mounting a number grid.

Import it

import type { KazuMountOptions } from "@johnmorrisdotca/kazu/play";

Definition

type KazuMountOptions = {
    kind: KazuKind;
    size: number;
    givens: string;
    solution?: string;
    level?: KazuLevel;
    seed?: number;
    run?: string;
    notes?: string;
    elapsed?: number;
    clock?: boolean;
    controls?: boolean;
    hints?: "place" | "show" | "off";
    check?: "count" | "show" | "off";
    conflicts?: boolean;
    peers?: boolean;
    tidy?: boolean;
    tapToStep?: boolean;
    language?: KazuLanguage;
    onChange?: (detail: KazuEventDetail) => void;
    onHint?: (detail: KazuEventDetail) => void;
    onCheck?: (detail: KazuEventDetail) => void;
    onSolve?: (detail: KazuEventDetail) => void;
};

Members

NameTypeDescription
kind"number-place" | "jigsaw" | "diagonal" | "sum-cages" | "more-or-less" | "towers"
sizenumber
givensstring

The puzzle's givens code.

solution (optional)string | undefined

The puzzle's one answer, as a cells code. Left out, it is worked out from the givens when Hint or Check needs it.

level (optional)"easy" | "medium" | "hard" | undefined

Which level and seed made it, to carry in the events.

seed (optional)number | undefined
run (optional)string | undefined

A run to start from: the entries of a puzzle half done (decodeRun's code).

notes (optional)string | undefined

Pencil marks to start from (decodeNotes's code).

elapsed (optional)number | undefined

Milliseconds already on the clock, to carry on a puzzle kept half done.

clock (optional)boolean | undefined

Show the clock, which starts on the first entry. Default true.

controls (optional)boolean | undefined

The number pad and the buttons under the board. Default true.

hints (optional)"place" | "show" | "off" | undefined

What Hint does: place writes the number it found (default), show only points at the cell and says why, off takes the button away.

check (optional)"show" | "off" | "count" | undefined

What Check does: count says how many cells are wrong (default), show marks them too, off takes the button away.

conflicts (optional)boolean | undefined

Draw the cells that break a rule in red as they are made. Default true.

peers (optional)boolean | undefined

Wash the chosen cell's row, column and group, and the cells holding its number. Default true.

tidy (optional)boolean | undefined

A number written takes itself out of the pencil marks of the cells it shares a group with. Default true.

tapToStep (optional)boolean | undefined

A tap on the chosen cell steps its number on. Default true.

language (optional)KazuLanguage | undefined

The language the words are in. Left out, the host's own lang, or the page's, and it follows the page's.

onChange (optional)((detail: KazuEventDetail) => void) | undefined
onHint (optional)((detail: KazuEventDetail) => void) | undefined
onCheck (optional)((detail: KazuEventDetail) => void) | undefined
onSolve (optional)((detail: KazuEventDetail) => void) | undefined

Examples

import type { KazuPuzzle } from "@johnmorrisdotca/kazu";
import { decodeCells } from "@johnmorrisdotca/kazu";
import type { KazuMountOptions } from "@johnmorrisdotca/kazu/play";

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 solution = decodeCells(answer,size)!;
const value: KazuMountOptions = {kind,size,givens,solution:answer,hints:"show"};
console.log(value);
{
  kind: 'number-place',
  size: 4,
  givens: '14..2..1412.3..4',
  solution: '1432234141233214',
  hints: 'show'
}

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kazu 2.1.0.