Reference · Pipes, rules and solving
checkSuidoAnswerfunction
Whether an answer solves a board: the check a page makes to say "solved" and a server makes before it trusts a solve. O(cells): one walk of the water, no search.
The answer is a code like the board's own. Every cell of it must be the piece the board has there, turned (a piece is never changed, moved or taken away), and the sources and drains must be where the board put them. Then the water is run from the sources through the answer's pieces, and the board must be solved: a network, every piece wet; drains, every drain wet; and either way no wet piece opens on nothing; an inlet-outlet board also asks that the water runs in one path. Locked pieces must be as the board gives them, and the walls must be the board's walls. A block that turns as one (big pieces and blocks) must be the block the board has there turned a whole number of quarters, never one piece of it turned alone.
It does not ask whether the board is one a site has made: a site that pays or ranks for a solve asks that first.
Import it
import { checkSuidoAnswer } from "@johnmorrisdotca/suido";
Definition
function checkSuidoAnswer(board: string, answer: string): SuidoCheck
Parameters
| Name | Type | Description |
|---|---|---|
board | string | The original native board code. |
answer | string | The solved pipe masks or encoded answer specified by the signature. |
Returns
SuidoCheck
Whether an answer solves a board: the check a page makes to say "solved" and a server makes before it trusts a solve. O(cells): one walk of the water, no search.
Examples
import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { levelAnswer } from "@johnmorrisdotca/suido/levels";
import { checkSuidoAnswer } from "@johnmorrisdotca/suido";
const row = SUIDO_5X5[0];
const code = row[0];
const answer = levelAnswer(row)!;
console.log(checkSuidoAnswer(code,answer));{ ok: true }What it prints (run when this page was built)