Brain-Flak是一种图灵化的语言,在PPCG上享有很高的声誉。语言的记忆是由两个堆栈组成,而是一个“隐藏”的第三组被发现由瓦é在向导,导致大脑思维,高射炮方案的一些有趣的新方式。
那么,如何给那个可怜的隐藏第三堆栈更多的可见性呢?让我们创建一种语言,使第三个堆栈具有应有的识别力!在这里,我向您介绍Third-Flak。
语言
在Third-Flak中,只有一个堆栈,称为第三堆栈。运营商在他们的脑高射炮做同样的方式在第三堆栈上工作,但这里没有[]
,{}
,<>
nilads没有{...}
单子(所以在第三高射炮程序的唯一受理字符()[]<>
)。这是每个运算符的工作(将给出示例,该示例表示第三个堆栈,并带有列表,其中最后一个元素是堆栈的顶部):
()
是Third-Flak中唯一的两个字符的运算符。它会将第三个堆栈的顶部加1。例如:[1,2,3]
→[1,2,4]
(
,[
,<
:未覆盖的前情况下,所有开口括号推0
至第三层叠体。例如:[1,2,3]
→[1,2,3,0]
)
从第三个堆栈中弹出两个元素,并推回它们的总和。例如:[1,2,3]
→[1,5]
]
从第三个堆栈中弹出两个元素,然后推回从第二个元素中减去第一个元素的结果。例如:[1,2,3]
→[1,-1]
>
从第三个堆栈中弹出一个元素。示例[1,2,3]
→[1,2]
这是该语言的其他规则:
在执行开始时,第三个堆栈仅包含单个0。
禁止在程序内部为空
[]
或<>
(如果遵循Third-Flak的语义,它们将始终是noop,但实际上它们在Brain-Flak中具有不同的含义,无法在此处重新创建)。括号总是需要平衡的,除非程序末尾的结尾的括号可能会丢失。例如,
[()<(()
是一个有效的Third-Flak程序(程序末尾的第三个堆栈为[1,0,1]
)。一个程序只能包含六个允许的字符
()[]<>
。程序保证是非空的。
注意:以前的规则暗示,您不必处理需要从空堆栈中弹出的情况。
挑战
很简单,为Third-Flak写一个解释器。您的程序必须将Third-Flak程序作为输入,并在程序末尾返回第三堆栈的状态作为输出。
您的输出格式是灵活的,只要可以从中明确读取第三个堆栈的状态,并且始终以相同的方式编码相同的数字(这只是一种说法,任何输出格式都不是公然的方式)尝试作弊就可以了)。
您的输出选择可能会限制您可以管理的数字范围,只要这不会使挑战变得微不足道(因为这将是默认漏洞)。
测试用例
对于每个测试用例,第一行是输入,第二行是输出堆栈,用空格分隔的数字列表表示,其中堆栈的顶部是最后一个元素。
[()<(()
0 1 0 1
[((((()()()()()))
0 0 0 5
((([()][()][()])))
-3
[<<(((()()()())(((((
0 0 0 0 0 4 0 0 0 0 0
[()]<(([()])><[()]
-1 0 -1
(())(()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(()()())(())(()()()()())(())(())(())(())(()()()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(()()())(())(()()()()())(())(())(())(())(())(())(()())(())(())(())(()())(()()()())(())(()()()()())(()())(()())(()())(()()())(())(()())(())(()()()()())(()())(()()()()())(())(())(())(())(())(()())(())(())(())(()()()()())(())(())(()()()()())(())(())(()()()()())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(()())(()())(()())(()())(())(()()()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(()()())(())(())(()()())(()())(())(()()()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(())(())(())(()()())(())(())(()()())(())(())(()()())(())(()()()()())(()())(()()()()())(()()())(())(()()())(())(())(())(()())(()()())(()())(())(()()()()())(()())(())(()()())(())(()()()()())(())(())(())(()()())(())(())(())(()())(())(()())(()()()())(())(())(()()()()())(()())(()())(())(()()())(())(())(())(())(()()())(()())(())(())(()()()()())(())(())(()()()()())(())(())(()()()()())(())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(())(()()()()())(()())(())(()()())(())(()()()()())(()()()()())(())(()()())(())(())(()())(())(()()()()())(())(()()()()())(())(())(())(()()()()())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(())(()()()()())(()())(())(()()())(())(())(()())(())(()()()()())(()())(()()()()())(())(()()())(())(())(()()()()())(())(()()()()())(())(())(())(()())(())(()()()()())(())(())(()())(())(()())(())(()())(()())(()())(()())(())(()()()()())(()())(())(()()()()())(())(()()())(())(())(()())(())(()()()()())(()())(()()()()())(())(()()())(())(())(())(()())(()()()())(())(())(()())(())(()()()()())(())(())(()()()()())(())(())(()()()()())(())(())(()())(())(()())(())(()())(())(()())(())(()())(()())(()())(()())(()())(()())(())(()()())(())(())(()())(())(()()()()())(()())(()()()()())(()()())(())(())(()())(())(())(()()()()())(()()()())(()())(()())(()()())(())(()())(())(()()()()())(()())(()()()()())(())(())(())(()()()())(()()()())(()()
718 2
e
是在这里。
[()]
会违反我们不必担心从空堆栈中弹出的规则