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 · Cross Sums rules

enterCrossSumsfunction

Apply the requested native CrossSums entry or mark to a new immutable game; invalid or fixed targets stay unchanged.

Import it

import { enterCrossSums } from "@johnmorrisdotca/kazu/cross-sums";

Also exported from: @johnmorrisdotca/kazu

Definition

function enterCrossSums(game: CrossSumsGame, cell: number, digit: number, pencil?: boolean): CrossSumsGame

Parameters

NameTypeDescription
gameCrossSumsGame

The current immutable game state.

cellnumber

A zero-based row-major cell index.

digitnumber

The digit to enter, or zero to clear.

pencil (optional)boolean

Whether to toggle a note rather than enter a digit.

Returns

CrossSumsGame

Apply the requested native CrossSums entry or mark to a new immutable game; invalid or fixed targets stay unchanged.

Examples

import type { CrossSumsBoard } from "@johnmorrisdotca/kazu/cross-sums";
import { enterCrossSums, newCrossSums } from "@johnmorrisdotca/kazu/cross-sums";

const crossSumsBoard: CrossSumsBoard = {"width":5,"height":5,"cells":[{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":10},{"kind":"black","across":null,"down":7},{"kind":"black","across":null,"down":12},{"kind":"black","across":null,"down":null},{"kind":"black","across":6,"down":null},{"kind":"white"},{"kind":"white"},{"kind":"white"},{"kind":"black","across":null,"down":null},{"kind":"black","across":23,"down":null},{"kind":"white"},{"kind":"white"},{"kind":"white"},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null},{"kind":"black","across":null,"down":null}]};
const crossSumsGame = newCrossSums(crossSumsBoard);
console.log(enterCrossSums(crossSumsGame,0,1,false));
{
  board: {
    width: 5,
    height: 5,
    cells: [
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object], [Object], [Object],
      [Object]
    ]
  },
  values: [
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0,
    0
  ],
  notes: [
    [], [], [], [], [], [], [], [],
    [], [], [], [], [], [], [], [],
    [], [], [], [], [], [], [], [],
    []
  ],
  history: [],
  helped: false
}

What it prints (run when this page was built)

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