Powershell、95バイト
ジョーイの答えに触発されました。
filter x{$_;$_[40..0]|%{$_-split'/'-replace'\\','/'-join'\'}},($args|%{-join(,($_|% t*y)|x)})|x
注:40
著者がコメントを投稿するためLet's say the input is at most 16 rows and 40 characters
。
テストスクリプト:
$f = {
filter x{$_;$_[40..0]|%{$_-split'/'-replace'\\','/'-join'\'}}
,($args|%{-join(,($_|% t*y)|x)})|x
}
@(
,( ("+---",
"|./.",
"|/.."),
"+------+",
"|./..\.|",
"|/....\|",
"|\..../|",
"|.\../.|",
"+------+")
,( ("+\/",
"/\/"),
"+\/\/+",
"/\/\/\",
"\/\/\/",
"+/\/\+")
,( ("+---",
"|...",
"|..\"),
"+------+",
"|......|",
"|..\/..|",
"|../\..|",
"|......|",
"+------+")
) | % {
$m,$expected = $_
$result = &$f @m
"$result"-eq"$expected"
$result
}
出力:
True
+------+
|./..\.|
|/....\|
|\..../|
|.\../.|
+------+
True
+\/\/+
/\/\/\
\/\/\/
+/\/\+
True
+------+
|......|
|..\/..|
|../\..|
|......|
+------+