本文へ移動

Suido水道

管を回してポンプと排水口をつなぎます。収録された問題やシード付きの問題で遊べます。

「水道」は、水を届ける設備を表す言葉です。 名前について(英語)

目次

リファレンス · 管・ルール・解法

Flow型

リファレンスの説明と例は英語です。見出しと目次は日本語です。

Where the water is on a board as it is turned: the whole picture, from the pump outwards.

インポート

import type { Flow } from "@johnmorrisdotca/suido";

定義

type Flow = {
    wet: boolean[];
    from: number[];
    entry: number[];
    depth: number[];
    spills: {
        cell: number;
        side: number;
    }[];
    order: number[];
    pieces: number;
    wetPieces: number;
    drains: number;
    wetDrains: number;
    solved: boolean;
};

メンバー

名前型説明
wetboolean[]

Whether the water has reached each cell.

fromnumber[]

The cell the water came from into each wet cell; -1 for a source and for a dry cell.

entrynumber[]

The side each wet cell was entered on, the side facing from; -1 for a source and for a dry cell.

depthnumber[]

How many cells the water went through to get to each wet cell, 0 at a source; -1 for a dry cell.

spills{ cell: number; side: number; }[]

Every opening of a wet piece that opens on nothing: the edge of the board, bare ground, or a piece that does not open back. The water runs out of each.

ordernumber[]

The wet cells in the order the water reaches them, nearest the source first.

piecesnumber

How many pieces the board has, and how many of them are wet.

wetPiecesnumber
drainsnumber

How many drains the board has, and how many are wet.

wetDrainsnumber
solvedboolean

Whether the board is solved: the water reaches what its kind asks, and nothing runs out (and on an inlet-outlet board, it runs in one path).

例

import { SUIDO_5X5 } from "@johnmorrisdotca/suido/levels-5x5";
import { decodeLayout, flowOf } from "@johnmorrisdotca/suido";
import { levelSolution } from "@johnmorrisdotca/suido/levels";
import type { Flow } from "@johnmorrisdotca/suido";

const row = SUIDO_5X5[0];
const code = row[0];
const layout = decodeLayout(code)!;
const solution = levelSolution(row)!;
const value: Flow = flowOf(layout,solution);
console.log(value);
{
  wet: [
    true, true, true, true, true,
    true, true, true, true, true,
    true, true, true, true, true,
    true, true, true, true, true,
    true, true, true, true, true
  ],
  from: [
    -1,  0,  1,  2,  3,  0,  7,  8,
    13, 14,  5, 10, 11, 12, 13, 10,
    11, 16, 13, 14, 15, 20, 21, 22,
    19
  ],
  entry: [
    -1, 3, 3, 3, 3, 0, 1, 1,
     2, 2, 0, 3, 3, 3, 3, 0,
     0, 3, 0, 0, 0, 3, 3, 3,
     0
  ],
  depth: [
    0, 1, 2, 3, 4, 1, 8, 7,
    6, 7, 2, 3, 4, 5, 6, 3,
    4, 5, 6, 7, 4, 5, 6, 7,
    8
  ],
  spills: [],
  order: [
     0,  1,  5,  2, 10,  3, 11, 15,
     4, 12, 16, 20, 13, 17, 21,  8,
    14, 18, 22,  7,  9, 19, 23,  6,
    24
  ],
  pieces: 25,
  wetPieces: 25,
  drains: 7,
  wetDrains: 7,
  solved: true
}

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/suido 1.7.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。