Skip to the content

Tsunagi繋ぎ

Join each pair with a separate line and fill the board, through fixed levels or seeded puzzles.

Tsunagi means joining in Japanese. About the name

Contents

Reference · Rules, solvers and generation

stepBetweenfunction

The way from a to its neighbour b as a step (-1, +1, -size, +size), counting a step across a wrapped edge as the step it is — right off the right edge is +1, though the cells' numbers differ by size - 1. On a hexagon, the two slanting steps too: up-right (1 - size) and down-left (size - 1). Zero for cells that are not neighbours.

Import it

import { stepBetween } from "@johnmorrisdotca/tsunagi";

Definition

function stepBetween(size: number, a: number, b: number, wrap: boolean, hex?: boolean): number

Parameters

NameTypeDescription
sizenumber

The number of cells on each side of the board.

anumber

The first cell index.

bnumber

The second cell index.

wrapboolean

Whether opposite board edges connect.

hex (optional)boolean

Whether to use hexagonal neighbours.

Returns

number

The way from a to its neighbour b as a step (-1, +1, -size, +size), counting a step across a wrapped edge as the step it is — right off the right edge is +1, though the cells' numbers differ by size - 1. On a hexagon, the two slanting steps too: up-right (1 - size) and down-left (size - 1). Zero for cells that are not neighbours.

Examples

import { stepBetween } from "@johnmorrisdotca/tsunagi";

console.log(stepBetween(4,0,1,false));
1

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/tsunagi 1.7.0.