介绍
字距调整是指调整文本字母之间的间距。例如,考虑Top
用以下三个字形写的单词:
##### ..... .....
..#.. ..... .....
..#.. ..##. .###.
..#.. .#..# .#..#
..#.. .#..# .#..#
..#.. ..##. .###.
..... ..... .#...
..... ..... .#...
我们可以用点填充字形之间的间隙并完成它,但是间隙看起来太宽了。相反,我们将字形滑动到左侧,以便它们几乎可以接触:
#####........
..#..........
..#..##..###.
..#.#..#.#..#
..#.#..#.#..#
..#..##..###.
.........#...
.........#...
看起来好多了!请注意,的条形图T
在的左边框上方o
。在此挑战中,您的任务是为此类矩形字形实现一个简单的字距调整程序。
字距调整过程
考虑具有.
和#
形状相同的两个矩形2D字符数组。在简单的字距调整过程中,我们首先将数组并排放置,中间放置一列.
s。然后,我们将#
右阵列中的每一个向左移动一步,直到#
左右阵列中的s正交或对角相邻。字距调整的结果是引入相邻s 之前的步骤#
。您的任务是实施此过程。
让我们举个例子:
Inputs:
..###
#....
#....
..##.
...#.
...##
..###
....#
Process:
..###....#.
#........##
#.......###
..##......#
..###...#.
#.......##
#......###
..##.....#
..###..#.
#......##
#.....###
..##....#
..###.#.
#.....##
#....###
..##...#
..####.
#....##
#...###
..##..#
在最后一个数组中,我们有#
s 对新相邻,因此倒数第二个数组是字距调整过程的结果。
输入输出
为简单起见,您只需要处理两个字形的字距调整。您的输入是两个矩形2D数组,采用以下格式之一:
- 二维整数数组,其中0代表
.
,1代表#
。 - 多行字符串
.#
。 - 上的字符串数组
.#
。 - 字符的2D数组
.#
。
如果输入是单个字符串,则可以使用任何合理的定界符。但是,分隔符应位于两个数组之间,这意味着不允许您将已经成对的两个输入逐行处理。
您的输出是应用于这两个数组的字距调整过程的结果,这是一个与输入格式相同的矩形2D数组。您可以添加或删除.
s的任意数量的前导列或尾随列,但是输出必须为矩形,并且具有与输入相同的高度。确保字距调整过程在第二个输入的左边缘滑过第一个输入的左边缘之前结束。
规则和计分
每种编程语言中的最低字节数为准。适用标准代码高尔夫球规则。
测试用例
为了帮助复制粘贴,这些测试用例以字符串列表形式给出。
["#"] ["#"] -> ["#.#"]
["#.","..",".#"] ["##","..","##"] -> ["#..##",".....",".#.##"]
["..#","#..","#.."] ["...","..#","###"] -> ["..#..","#...#","#.###"]
["###.","##..","#...","...."] ["....","...#","..#.",".#.."] -> ["###..","##..#","#..#.","..#.."]
["..##...","#......","#......"] [".....##",".....##",".#...#."] -> ["..##..##","#.....##","#.#...#."]
["...#.",".....",".....",".....","....#"] [".....","....#","#....",".....","....."] -> ["...#..",".....#",".#....","......","....#."]
["..#..",".....",".....",".....","....#"] [".....","....#","#....",".....","....."] -> ["..#..","....#","#....",".....","....#"]
["######","#.....","#.....","#.....","######"] ["......",".....#",".#...#",".....#","......"] -> ["######..","#......#","#..#...#","#......#","######.."]
["######","#.....","#.....","#.....","######"] ["......","......",".#....","......","......"] -> ["######","#.....","#.#...","#.....","######"]
["#...#","#..#.","#.#..","##...","#.#..","#..#.","#...#"] ["...#.","..#..",".#...",".#...",".#...","..#..","...#."] -> ["#...#..#","#..#..#.","#.#..#..","##...#..","#.#..#..","#..#..#.","#...#..#"]