Reference · Rules, solvers and generation
neighboursOffunction
The four neighbours of a cell on a square grid, as indexes; fewer at an edge.
Import it
import { neighboursOf } from "@johnmorrisdotca/tsunagi";
Definition
function neighboursOf(size: number, at: number): number[]
Parameters
| Name | Type | Description |
|---|---|---|
size | number | The number of cells on each side of the board. |
at | number | The zero-based cell index. |
Returns
number[]
The four neighbours of a cell on a square grid, as indexes; fewer at an edge.
Examples
import { neighboursOf } from "@johnmorrisdotca/tsunagi";
console.log(neighboursOf(4,0));[ 1, 4 ]What it prints (run when this page was built)