Reference · Pipes, rules and solving
usedPiecesOffunction
How many pieces the water goes through in an answer.
Import it
import { usedPiecesOf } from "@johnmorrisdotca/suido";
Definition
function usedPiecesOf(layout: Layout, solution: readonly number[]): number
Parameters
| Name | Type | Description |
|---|---|---|
layout | Layout | The decoded board with its dimensions, pipe masks and rule settings. |
solution | readonly number[] | The solved pipe masks in row-major cell order. |
Returns
number
How many pieces the water goes through in an answer.
Examples
import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { decodeLayout, usedPiecesOf } 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(usedPiecesOf(layout,solution));25What it prints (run when this page was built)