4P.a+80pa2*&wdt,kd&w74*,.ok@
在线尝试!
不可打印字符为0x18。
说明
通常的"
基于Fungeoid quines的问题在于,如果我们重复整个源代码,那么我们还会得到更多信息"
,并且字符串不再覆盖整个源代码。我认为这就是为什么现有答案使用cheat-y g
方法的原因。
这个答案确实使用了"
基于-的方法,但是我们没有"
在源代码中包含-,而是在运行时将其写入程序中。这样,"
无论重复程序的频率如何,都将只有一个(因为我们仅将其写入一个特定的坐标,而与程序的大小无关)。
然后,一般的想法是,我们在堆栈上创建整个源代码的表示,但是仅循环通过字符的前29个字符(即程序长度),而循环的长度由代码的大小确定。因此,我们实际上可以在其后附加任意字符(换行符除外),@
并且结果始终是核心程序的循环重复,比源代码长一个字符。
4P Push 4! = 24. This is the code point of the unprintable, which we're
using as a placeholder for the quote.
.a+ Duplicate it and add 10, to get 34 = '"'.
80p Write '"' to cell (8,0), i.e. where the first unprintable is.
Placeholder, becomes " by the time we get here, and pushes the code
points of the entire program to the stack. However, since we're already
a good bit into the program, the order will be messed up: the bottom
of the stack starts at the 24 (the unprintable) followed by all
characters after it (including those from extraneous repetitions). Then
on top we have the characters that come in front of the `"`.
So if the initial program has structure AB, then any valid program has
the form ABC (where C is a cyclic repetition of the initial program),
and the stack ends up holding BCA. We don't care about C, except to
determine how big the program is. So the first thing we need to do is
bring B to the top, so that we've got the initial program on top of
the stack:
a2* Push 10*2 = 20.
&w Run the following section 21 times, which is the length of B.
dt, Pull up the value at the bottom of the stack.
k End of loop.
d&w Run the following section D+1 times, where D is the length of ABC.
74* Push 28, one less than the number of characters in AB.
, Pull up the 29th stack element, which is the next character to print.
.o Print a copy of that character.
k End of loop.
@ Terminate the program.