介绍
在这个挑战中,索引2×2的矩阵是这样的:
0 1
2 3
我们定义了一系列类似分形的图案F(L)
,其中L
是n
这些索引的长度列表,并且F(L)
具有size 。2n-1 × 2n-1
- 如果
L == []
,F(L)
则为1×1模式#
。 如果
L != []
,则F(L)
构造如下。取P
为L
删除第一个元素后获得的图案。取4个大小充满周期的网格,并用模式替换用索引的网格。然后,使用网格之间的一层哈希将网格粘合在一起。这是四种情况的图表:2n-1-1 × 2n-1-1
.
L[0]
P
#
L[0]==0 L[0]==1 L[0]==2 L[0]==3 #... ...# ...#... ...#... [P]#... ...#[P] ...#... ...#... #... ...# ...#... ...#... ####### ####### ####### ####### ...#... ...#... #... ...# ...#... ...#... [P]#... ...#[P] ...#... ...#... #... ...#
例
考虑输入L = [2,0]
。我们从1×1网格开始#
,然后L
从右侧遍历。最右边的元素是0
,因此我们获取1×1网格的四个副本.
,将第一个替换为#
,然后将它们与哈希值粘合在一起。结果是3×3网格
##.
###
.#.
下一个元素是2
,因此我们获取.
s 的3×3网格的四个副本,并用上述网格替换第三个。四个网格是
... ... ##. ...
... ... ### ...
... ... .#. ...
并将它们与#
s 粘合在一起,得到7×7的网格
...#...
...#...
...#...
#######
##.#...
####...
.#.#...
这是我们的最终输出。
输入值
您的输入是L
索引列表0, 1, 2, 3
。您可以将其视为整数列表或一串数字。请注意,它可能为空,并且可能包含重复项。的长度L
最多为5。
输出量
您的输出是模式F(L)
,以换行符分隔的字符串。
规则和计分
您可以编写完整的程序或函数。最低的字节数为准,并且不允许出现标准漏洞。
测试用例
[]
#
[0]
##.
###
.#.
[3]
.#.
###
.##
[2,0]
...#...
...#...
...#...
#######
##.#...
####...
.#.#...
[1,1]
...#.##
...####
...#.#.
#######
...#...
...#...
...#...
[1,2,0]
.......#...#...
.......#...#...
.......#...#...
.......########
.......###.#...
.......#####...
.......#.#.#...
###############
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
[3,3,1]
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
.......#.......
###############
.......#...#...
.......#...#...
.......#...#...
.......########
.......#...#.##
.......#...####
.......#...#.#.
[0,1,2,3]
.......#...#...#...............
.......#...#...#...............
.......#...#...#...............
.......#########...............
.......#.#.#...#...............
.......#####...#...............
.......#.###...#...............
################...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
.......#.......#...............
###############################
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
...............#...............
[0,0,1,2,3]
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#...#...#...............#...............................
.......#########...............#...............................
.......#.#.#...#...............#...............................
.......#####...#...............#...............................
.......#.###...#...............#...............................
################...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
.......#.......#...............#...............................
################################...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
...............#...............#...............................
###############################################################
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
...............................#...............................
L = [2,0]
,您先砍下头看一下图案F([0])
,然后砍下头[0]
看一下图案F([])
(即1x1网格)#
。然后,使用切碎的索引0
建立3x3模式,并使用切碎的索引2
建立7x7模式。要回答您的问题:是的,您总是从1x1网格开始,因为这是递归的基本情况。
#
?L !=[]
在该示例中,因为它具有1个或多个元素。这是否意味着F(L)首先始终是a#
?