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

KazuEventDetailtype

What every event tells of the board.

Import it

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

Definition

type KazuEventDetail = {
    kind: KazuKind;
    size: number;
    level?: KazuLevel;
    seed?: number;
    run: string;
    notes: string;
    answer: string;
    progress: {
        filled: number;
        total: number;
    };
    elapsedMs: number;
    hints: number;
    checks: number;
    helped: boolean;
    solved: boolean;
    hint?: KazuHint;
};

Members

NameTypeDescription
kind"number-place" | "jigsaw" | "diagonal" | "sum-cages" | "more-or-less" | "towers"
sizenumber
level (optional)"easy" | "medium" | "hard" | undefined
seed (optional)number | undefined
runstring

What the player has written, as a run's code (decodeRun brings it back): to keep a puzzle half done.

notesstring

The pencil marks, as a code (decodeNotes). Empty for none.

answerstring

The whole grid, printed numbers and the player's: what checkKazu takes as an answer.

progress{ filled: number; total: number; }
elapsedMsnumber

The time on the clock, in milliseconds.

hintsnumber

How many hints were taken, and how many times Check was pressed. A solve with any hint is a helped one.

checksnumber
helpedboolean
solvedboolean
hint (optional)KazuHint | undefined

For kazu-hint: what the hint said.

Examples

import type { KazuPuzzle } from "@johnmorrisdotca/kazu";
import { answerOf, decodeCells, encodeNotes, encodeRun, isSolved, kazuProgress, newKazuGame } from "@johnmorrisdotca/kazu";
import type { KazuEventDetail } 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 game = newKazuGame(kind,size,givens)!;
const value: KazuEventDetail = {kind,size,run:encodeRun(game.entries),notes:encodeNotes(game.notes),answer:answerOf(game),progress:kazuProgress(game),elapsedMs:0,hints:0,checks:0,helped:false,solved:isSolved(game)};
console.log(value);
{
  kind: 'number-place',
  size: 4,
  run: '................',
  notes: '',
  answer: '14..2..1412.3..4',
  progress: { filled: 9, total: 16 },
  elapsedMs: 0,
  hints: 0,
  checks: 0,
  helped: false,
  solved: false
}

What it prints (run when this page was built)

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