程序应该从两个单独的文件开始,这里的文件名为"a“和"b”。"a“和"b”应该是我所说的逆quines:"a“在运行时应该输出"b"'s源代码,而"b”在运行时应该输出"a"'s源代码,例如:
./a
#source code of b, optionally followed by newlines
./b
#source code of a, optionally followed by newlines如果"a“和"b”的输出随后附加到同一个文件,这里称为"c",如下所示:
touch c
./a >> c
./b >> c结果文件"c“在运行时,应该输出"a”的代码,后面是换行符,后面是"b“的源代码和一个换行符。这些文件的完整运行应如下所示:
touch c
./a >> c
./b >> c
./c
#source code of a \n
#source code of b \n任何编码语言都可以使用,因为这是代码高尔夫,源代码应该尽可能小。
没有限制"a“和"b”的源代码可以是什么,换行符可以自由放置在代码输出的末尾,这样输出以单行或换行符结束。
发布于 2021-02-16 09:24:10
"34çìD«r»¨"34çìD«r»¨"34çìD«r»¨"34çìD«r»"34çìD«r»¨"34çìD«r»¨"34çìD«r»¨"34çìD«r»方案a:
"34çìD«r»¨" # Push string '34çìD«r»¨'
34 # Push 34
ç # Convert it to a character: '"'
ì # Prepend it in front of the string: '"34çìD«r»¨'
D # Duplicate it
« # Merge the copy to itself: '"34çìD«r»¨"34çìD«r»¨'
r # Reverse the items on the stack
# (no-op, since there is just a single item)
» # Join all items on the stack by newlines
# (no-op, since there is just a single item)
¨ # Remove the last character: '"34çìD«r»¨"34çìD«r»'
# (after which the result is output implicitly)方案b:
与程序a相同,但是没有尾随的¨,因此它将输出"34çìD«r»¨"34çìD«r»¨ (是程序a)。
方案c:
"34çìD«r»¨"34çìD«r»¨ # It starts the same as program a
"34çìD«r»¨" # Push string '34çìD«r»¨'
# STACK: ['"34çìD«r»¨"34çìD«r»', '34çìD«r»¨']
34çìD« # Do the same as above
# STACK: ['"34çìD«r»¨"34çìD«r»', '"34çìD«r»¨"34çìD«r»¨']
r # Reverse the items on the stack
# STACK: ['"34çìD«r»¨"34çìD«r»¨', '"34çìD«r»¨"34çìD«r»']
» # Join all items on the stack by newlines
# STACK: ['"34çìD«r»¨"34çìD«r»¨\n"34çìD«r»¨"34çìD«r»']
# (after which the result is output implicitly)https://codegolf.stackexchange.com/questions/219113
复制相似问题