本文へ移動

Tsunagi繋ぎ

同じ印の2つを別々の線で結び、盤を埋めます。収録された問題やシード付きの問題で遊べます。

「つなぎ」は、物をつなぐことを表す言葉です。 名前について(英語)

目次

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

withBridges関数

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

Lines that fill a board with want bridges made in them: where a line runs straight through a cell away from the edge and two other lines each end on the cells either side of it the other way, those two are joined into one line over the cell, which becomes a bridge. Null where they offer no place for them.

インポート

import { withBridges } from "@johnmorrisdotca/tsunagi";

定義

function withBridges(size: number, lines: readonly number[][], random: Random, want: number): { paths: number[][]; bridges: Set<number>; } | null

引数

名前型説明
sizenumber

The number of cells on each side of the board.

linesreadonly number[][]

The lines that fill the board.

randomRandom

A reproducible random source returning values in [0,1).

wantnumber

The requested number of bridges.

戻り値

{ paths: number[][]; bridges: Set<number>; } | null

The lines and the bridges, or null.

例

import { randomFilling, seededRandom, withBridges } from "@johnmorrisdotca/tsunagi";

const random = seededRandom(42);
const lines = randomFilling(6,random,12);
console.log(lines === null ? null : withBridges(6,lines,random,1));

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

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