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 · Number-puzzle engines

encodeKillerfunction

A Sum Cages puzzle's givens: the cells, then which cage each cell is in, then each cage's sum.

cells is size² characters as every number puzzle writes them (all empty, usually; a cage of one cell is its own given). cages is size² characters, one per cell, naming its cage from CAGE_LETTERS. sums is two base-36 characters a cage, in cage order. The cages ride in the givens because they are the puzzle.

Import it

import { encodeKiller } from "@johnmorrisdotca/kazu";

Definition

function encodeKiller(cells: readonly number[], cages: readonly Cage[]): string

Parameters

NameTypeDescription
cellsreadonly number[]

Row-major numeric cells, or expected cell count for step logs as specified by the signature.

cagesreadonly Cage[]

The cage cell lists and required sums.

Returns

string

A Sum Cages puzzle's givens: the cells, then which cage each cell is in, then each cage's sum.

Examples

import type { KazuPuzzle } from "@johnmorrisdotca/kazu";
import { decodeKiller, encodeKiller, 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 printed = readGivens(kind,size,givens)!;
const cells = printed.cells;
const killer = decodeKiller("2.....3..2................2...4.....012333412567882967aaa9bbccd9ebfgggee02050c0d03020309080e0c0a06020b040a",6)!;
console.log(encodeKiller(killer.cells,killer.cages));
2.....3..2................2...4.....012333412567882967aaa9bbccd9ebfgggee02050c0d03020309080e0c0a06020b040a

What it prints (run when this page was built)

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