Reference · Rules, solvers and generation
absorbfunction
Joins a short run of cells onto the end of a line beside it, keeping every line clear of itself.
Import it
import { absorb } from "@johnmorrisdotca/tsunagi";
Definition
function absorb(run: number[], paths: number[][], owner: Int16Array, around: readonly (readonly number[])[]): boolean
Parameters
| Name | Type | Description |
|---|---|---|
run | number[] | The short run of cells. |
paths | number[][] | The lines so far, one of which may take it. |
owner | Int16Array<ArrayBufferLike> | Which line owns each cell. |
around | readonly (readonly number[])[] | What is beside each cell. |
Returns
boolean
Whether a line took it.
Examples
import { absorb } from "@johnmorrisdotca/tsunagi";
const owner = new Int16Array(4).fill(-1);
owner[0] = owner[1] = owner[2] = 0;
console.log(absorb([3],[[0,1,2]],owner,[[1],[0,2],[1,3],[2]]));trueWhat it prints (run when this page was built)