Reference · Pipes, rules and solving
turnsFromAnswerfunction
The turns a board needs, when taps turn a piece either way: how far it is from solved.
Import it
import { turnsFromAnswer } from "@johnmorrisdotca/suido";
Definition
function turnsFromAnswer(given: readonly number[], solution: readonly number[]): number
Parameters
| Name | Type | Description |
|---|---|---|
given | readonly number[] | The starting pipe masks. |
solution | readonly number[] | The solved pipe masks in row-major cell order. |
Returns
number
The turns a board needs, when taps turn a piece either way: how far it is from solved.
Examples
import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { decodeLayout, turnsFromAnswer } from "@johnmorrisdotca/suido";
import { levelSolution } from "@johnmorrisdotca/suido/levels";
const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
const solution = levelSolution(row)!;
console.log(turnsFromAnswer(layout.cells,solution));23What it prints (run when this page was built)