给出了使用Brainfuck命令编写的随机代码。您的程序应该将该代码转换为以下ascii技巧:每个Brainfuck命令表示为5x9数组的A和B符号。所有命令都与5x3数组的A符号连接。符号A和B你选择自己。
例如,当输入为><+,.[]时,程序可能会输出:
== == = = = = = = =
== == = = =
== == = = = = = = =
== == = = = = =
== == = = = = = = = = 或
@@ @@ @ @ @ @ @ @ @
@@ @@ @ @ @
@@ @@ @ @ @ @ @ @ @
@@ @@ @ @ @ @ @
@@ @@ @ @ @ @ @ @ @ @ 甚至
..ooooooooooooooooo..ooooooo.ooooooooooooooooooooooooooooooooo.o.o.ooooooo.o.o.oo
oooo..ooooooooo..ooooooooooo.ooooooooooooooooooooooooooooooooo.ooooooooooooooo.oo
ooooooo..ooo..oooooooooo.o.o.o.o.ooooooooooooooooooooooooooooo.ooooooooooooooo.oo
oooo..ooooooooo..ooooooooooo.ooooooooooo.ooooooooooo.ooooooooo.ooooooooooooooo.oo
..ooooooooooooooooo..ooooooo.oooooooooo.oooooooooooooooooooooo.o.o.ooooooo.o.o.oo等等,尾随空格和A符号是允许的。
保证输入仅由符号> < + , . [ ]组成。
这是一个代码-高尔夫挑战,所以最短的解决方案获胜。
发布于 2022-02-21 18:48:37
“ṾÆxÑ3øḤC⁵ịJYSLẇɱ⁼’Bs3ŒBJṫ⁴Ɗ¦z1m€0Ṛs€9
⁽HṠ,17ḥⱮịⱮ¢j€⁶ẋ3¤Y接受字符串作为输出结果的第一个程序参数的完整程序,使用0表示墨迹,而1不使用墨水。
在网上试试! (页脚将1s替换为空格,以便于检查)。
“...’Bs3ŒBJṫ⁴Ɗ¦z1m€0Ṛs€9 - Link 1: no arguments
“...’ - 43552819895870853685529620449548093603391
B - in binary
s3 - split into chunks of length 3
-> columns of the bottom half of 5 of the 7 characters
the '[' and '>' are created using reflection later
the comma is reversed too, we'll use its reflection
¦ - sparse application...
Ɗ - ...to indices: last three links as a monad:
J - range of length
⁴ - 16
ṫ - tail (covers the columns containing ',' and '.')
ŒB - ...apply: bounce ("something" -> "somethingnihtemos")
z1 - transpose with filler 1 (fills where we didn't reflect)
m€0 - reflect each (constructing our ']', '>', and ',')
Ṛ - reverse
-> a list of the lines of a representation (without
any spacing) of ",.+<][>+.," where the first
comma is reversed.
s€9 - split each line into chunks of length 9
⁽HṠ,17ḥⱮịⱮ¢j€⁶ẋ3¤Y - Main Link: list of characters, C
⁽HṠ,17 - [19206,17]
Ɱ - map across C with:
ḥ - hash with salt 19206 and domain [1,2,...,17]
-> maps: ".[,+<]>" to 2,6,10,13,14,15,17
¢ - call Link 1 as a nilad
Ɱ - map across the lines of the result with:
ị - index into
-> 1-indexed and modular, so e.g. 17 gets the 7th item,
the part of the line for a '>'.
¤ - nilad followed by links as a nilad:
⁶ - space character
ẋ3 - repeated three times
j€ - join each list of line parts with three spaces
Y - join with newline characters
- implicit, smashing print发布于 2022-03-08 12:50:35
lambda s:'\n'.join(list(map(lambda i:print("111".join([list(map(lambda s:str(s)[3:],map(bin,[0x9FFF9EFFFFFF57AB,0xF9F9FEFFFFFF7FFB,0xFF0FEAAFFFFF7FFB,0xF9F9FEFF7FBF7FFB,0x9FFF9EFEFFFF57AB])))[i][(p:="><+,.[]".index(c))*9:(p+1)*9]for c in s])),[0,1,2,3,4])))我不知道为什么它给我一个TypeError,但它有效:)
https://codegolf.stackexchange.com/questions/243164
复制相似问题