您将使用表示一段brainfuck代码和说明的字符串,其中只包含可打印的ASCII字符和换行符( to ~、ASCII 10和32至126)作为输入和输出该代码的说明,格式为符合堆栈Exchange标记。
也就是说,解释必须满足:
<>+-.,[]之一的操作)都在一行上分组。```行,或者<pre><code>行和尾随的</code></pre>例如,如果代码是+[]Loop,则说明(没有“解释”)将被格式化为
+[]Loop
+
[
]
Loop<pre><code>+[]Loop
+
[
]
Loop
</code></pre>+[]环
[
]
循环播放
每个字符的说明将作为输入提供:
Move the pointer to the right
Move the pointer to the left
Increment the memory cell at the pointer
Decrement the memory cell at the pointer
Output the character signified by the cell at the pointer
Input a character and store it in the cell at the pointer
Jump past the matching ] if the cell at the pointer is 0
Jump back to the matching [ if the cell at the pointer is nonzero
No Operation输入始终包含9个解释字符串。
答案可以选择如何将每个brainfuck命令与每个解释相关联。
您可以使用数组。
现在,我们可以将这些解释添加到示例代码中,以获得
+[]Loop
+ Increment the memory cell at the pointer
[ Jump past the matching ] if the cell at the pointer is 0
] Jump back to the matching [ if the cell at the pointer is nonzero
Loop No Operation(使用4个前导空格,而不是反勾选围栏或HTML标记)。
这是密码-高尔夫,所以以字节为单位的最短代码获胜。
输入:
[]<>{}()++--..,,
Move the pointer to the right
Move the pointer to the left
Increment the memory cell at the pointer
Decrement the memory cell at the pointer
Output the character signified by the cell at the pointer
Input a character and store it in the cell at the pointer
Jump past the matching ] if the cell at the pointer is 0
Jump back to the matching [ if the cell at the pointer is nonzero
No Operation输出:
[]<>{}()++--..,,
[ Jump past the matching ] if the cell at the pointer is 0
] Jump back to the matching [ if the cell at the pointer is nonzero
< Move the pointer to the left
> Move the pointer to the right
{}() No Operation
+ Increment the memory cell at the pointer
+ Increment the memory cell at the pointer
- Decrement the memory cell at the pointer
- Decrement the memory cell at the pointer
. Output the character signified by the cell at the pointer
. Output the character signified by the cell at the pointer
, Input a character and store it in the cell at the pointer
, Input a character and store it in the cell at the pointer输入:
Brainfuck Power.
Move the pointer to the right
Move the pointer to the left
Increment the memory cell at the pointer
Decrement the memory cell at the pointer
Output the character signified by the cell at the pointer
Input a character and store it in the cell at the pointer
Jump past the matching ] if the cell at the pointer is 0
Jump back to the matching [ if the cell at the pointer is nonzero
No Operation输出:
Brainfuck Power。
Brainfuck电源无操作
. Output the character signified by the cell at the pointer输入:
>++++++[{{<,.>-}}]
Move the pointer to the right
Move the pointer to the left
Increment the memory cell at the pointer
Decrement the memory cell at the pointer
Output the character signified by the cell at the pointer
Input a character and store it in the cell at the pointer
Jump past the matching ] if the cell at the pointer is 0
Jump back to the matching [ if the cell at the pointer is nonzero
No Operation输出:
<pre><code>>++++++[{{<,.>-}}]
> Move the pointer to the right
+ Increment the memory cell at the pointer
+ Increment the memory cell at the pointer
+ Increment the memory cell at the pointer
+ Increment the memory cell at the pointer
+ Increment the memory cell at the pointer
+ Increment the memory cell at the pointer
[ Jump past the matching ] if the cell at the pointer is 0
{{ No Operation
< Move the pointer to the left
, Input a character and store it in the cell at the pointer
. Output the character signified by the cell at the pointer
> Move the pointer to the right
- Decrement the memory cell at the pointer
}} No Operation
] Jump back to the matching [ if the cell at the pointer is nonzero
</code></pre>输入:
><+-.,NOP[]
Move
Move
Increment
Decrement
STD
STD
While
While
NOP输出:
><+-.,NOP[]
> Move
< Move
+ Increment
- Decrement
. STD
, STD
NOP NOP
[ While
] While输入:
-\
Blah
Blah
Blah
Decrement
Blah
Blah
Blah
Blah
Nothing happens here输出:
-\
- Decrement
\ Nothing happens here发布于 2021-11-18 16:39:02
å☺m█Q╗½§ÄN!╢┼♫mù}Jt→v)╢+Θ☼î╔↓bÉü╡⌐CÇ-♠•¿♪FM¥2在Fmbalbuena在TNB的挑战之后。也会尝试在Pip中发布一些东西。
尼尔指出了一个错误后找到了一个漂亮的扑救。
LBc4NtPY{"><+-.,[]"XI^i*}/zsFs%Ntcaay%^(x_Iasn@as+4NtPs
LBc4NtPY{" No Operation
> Move the pointer to the right
< Move the pointer to the left
+ Increment the memory cell at the pointer
- Decrement the memory cell at the pointer
. Output the character signified by the cell at the pointer
, Input a character and store it in the cell at the pointer
[ Jump past the matching ] if the cell at the pointer is 0
] Jump back to the matching [ if the cell at the pointer is nonzero
"XI^i*}/zsFs%Ntcaay%^(x_Iasn@as No Operation
+ Increment the memory cell at the pointer
4NtPs No Operation发布于 2021-11-18 06:03:50
s=>a=>" "+s+s.replace(/(?:[^+-.<>[\]]+|.)(?=(.*))/g,(c,e)=>`
`+(c+e.replace(/.|$/g,' ')).padStart(s.length+5)+a.at('><+-.,[]'.indexOf(c)))f: (source_code: string) => (explain_array: string[]) => stringhttps://codegolf.stackexchange.com/questions/237408
复制相似问题