空白和Perl,992 975个字符
先生们女士们晚上好。
首先,这是我提交的内容以base64编码的代码,我认为这是交流大型Whitespace程序的最佳方法。(您确实不希望使用使所有空格保持原样的编码,因此没有必要选择更“可读”的东西。)
c2F5PDwgeDI7c2F5PDwwLDAgIApzYXk8PCB4MjtzYXk8PDAsMCAgCgoJCQogICAJCSAgCSAgCSAJ
CSAgCSAgCQkgCSAJIAkJCQkJICAJCSAJCQkgCQkJCQkgCSAJIAkJIAkgCSAgIAkJCQkJICAgCQkg
IAkgCQkgCSAJCSAJICAgIAkJCQkgCSAgCSAJCSAJICAgIAkgCQkgICAJICAgICAgCQkJIAkJCQkJ
IAkJCSAJCQkJICAgICAJCQkgCSAgICAgIAkJCQkJICAgICAgCQkgICAJCSAgICAJCQkJCQkJCSAg
CSAJIAkgICAJCQkgICAJCQkJCSAgCQkJCSAJICAgIAkgCQkJCQkgCSAgICAgCSAgCSAJICAgICAg
CSAgICAJICAgICAJCSAgIAkJCSAJIAkJCQkJCSAJCSAJIAkgICAgICAgCQkgIAkgICAgICAgICAg
IAkJICAgCSAJCQkgCSAgICAgCQkJCQkJIAkgICAgCQkJCSAJCQkJICAJCQkgICAJCQkgCSAgCSAg
IAkJCQkgIAkJIAkJCSAgIAkJCSAJCQkgCQkJICAJCSAJICAJIAkJCSAJIAkgCQkgICAgIAkgCSAJ
ICAJICAJIAkJICAgICAJIAkgICAgCQkJCSAgCSAJCSAJIAkJIAkgIAkgCSAJCSAJCSAJCSAJCQkg
CQkJICAgIAkJCSAgCSAgCQogICAJICAgICAJCQkJCSAJCSAJIAkgCSAJICAJCQkgICAJICAgCSAg
ICAJCSAJICAgICAgICAgCSAgIAkJCQkgCQkgICAgCQkgCSAJICAJCQkgCQkJCSAJCQkgICAJICAg
IAkgCSAJCQkgIAkJCQkgCSAJCSAJIAkgCQkJCSAJICAJIAkJIAkgICAJCiAKICAKICAgIAogCSAg
CQoKICAJCiAKICAgIAkJCQkgCSAKCSAJCQkKICAgICAJCQkJIAkgCgkgCSAgCiAgIAkJCgkgIAoK
CQkJCiAKCgoJIAkKICAgCSAgIAkgIAoKIAkKIAkgIAkKCiAJIAogICAJIAoKIAkKCiAJIAoKIAkK
CQogCSAgIAkgCgogCQoKCgoKICAgCiAgIAogCiAKIAkKCiAJCgogICAgCiAKIAoJIAogCiAgICAJ
IAoJIAkJIAoJICAgCSAKCSAJIAogCSAgCgogIAogCiAgICAJCQoJIAkJICAJCSAJCQkKCSAgCiAg
CQkJICAgCgkgCQkgICAJICAgICAKCSAgIAkKICAgICAJCQoJIAkgIAogICAJCQoJICAKCgkJCiAK
CgoJCjAK
这是摘录,突出显示了源代码的所有可见部分。⇥
用于指示选项卡和↲
指示换行符。
say<< x2;say<<0,0 ↲
say<< x2;say<<0,0 ↲
↲
⇥⇥↲
⇥⇥ ⇥ [... etcetera ... skipping rest of a really long line ...]↲
⇥⇥⇥ ⇥⇥[... etcetera ... shorter but still quite a long line ...]↲
↲
↲
↲
⇥ ⇥↲
[... etcetera ... whole lotta whitespace in here ...]
⇥⇥↲
↲
↲
↲
⇥↲
0↲
在这种挑战中,Perl是第二语言的自然选择,它是用于编写紧凑的quines的最佳通用语言之一。我最短的Perl quine是19个字节:
say<< x2
say<< x2
–您会看到它是Perl一半的双藜种子的种子。相比之下,我最好的Whitespace quine长541个字节。(尽管确实存在更短的字节-我见过的最好的是445个字节。)
从Perl解释器的角度来看,双quine源文件的第一行包含构成整个程序的两条语句,因为其余内容是两个带引号的字符串。第一个字符串是Perl的重复行,并由空白的第三行定界。第二个字符串全为空格,从源代码的第四行一直到0
文件底部的定界符。
当作为空白程序时,前四行包含三条几乎没有用的指令。(它们的作用是将两个零值压入堆栈,然后丢弃第二个零值。)包括它们只是为了安全地超过Perl程序所需的换行符–实际程序在此之后开始。而不是进一步引用不可读的源代码,这里是对组成空白程序的指令的解释,类似于汇编形式:
# Representation of "say<< ;say<<0,0 \n" in base 122 as ASCII chars.
PERLCODE = 44892457841068708924520433691075560592081
# Represention of the whitespace program, following the "push PERLCODE"
# instruction, in base 3 (see comments on wsout).
WSCODE = 9823454421986355730445143846606456399449033186160554878002671428613111806443504867738858766142050504887335990409088441824104338753030405625930185
# Set up the stack and the heap. The first three instructions are not
# particularly useful; they're just there to skip past the newlines in
# the Perl code. (Though the initial zero on the stack does get used
# at the very end.)
push 0
push 0
jneg wsout
push WSCODE
push PERLCODE
dup
dup
push 0
copy 1
# Output the first four lines of the file.
perl: dup
mod 122
putchar
div 122
dup
jnzero perl
pop
jzero perl
push 68 # represents "jneg wsout"
call wsout
# Output the rest of the file.
copy 1
call pushout
push 2
call wsout
call pushout
call wsout
putnum
push 2
call wsout
exit
# pushout: Output a Whitespace push instruction, using the number on
# the top of the stack as the instruction's argument. (Recursion is
# used to output the bits MSB-first.)
pushout:
push 0
dup
call wsout
call wsout
bits: dup
jzero bitend
dup
mod 2
swap
div 2
call bits
bitend: call wsout
ret
# wsout: Output a sequence of whitespace characters as represented by
# the number on the top of the stack. The number is read in base 3,
# LSB-first, with 0 = SPC, 1 = TAB, 2 = NL. Calling wsout with a value
# of zero will output a single space.
wsout:
dup
mod 3
mul -23 # some ugly math that transforms
mod -24 # (0, 1, 2) into (32, 9, 10)
add 32
putchar
div 3
dup
jnzero wsout
pop
ret
顶部的巨大数字是Whitespace用户用来代替实际字符串的工具。不要费力尝试在没有适当的bignum支持的Whitespace解释器上运行此代码。
最后,这里再次是程序,但是这次是C样式转义,因为它是特别要求的:
say<< x2;say<<0,0 \nsay<< x2;say<<0,0 \n\n\t\t\n \t\t \t \t \t\t \t \t\t \t \t \t\t\t\t\t \t\t \t\t\t \t\t\t\t\t \t \t \t\t \t \t \t\t\t\t\t \t\t \t \t\t \t \t\t \t \t\t\t\t \t \t \t\t \t \t \t\t \t \t\t\t \t\t\t\t\t \t\t\t \t\t\t\t \t\t\t \t \t\t\t\t\t \t\t \t\t \t\t\t\t\t\t\t\t \t \t \t \t\t\t \t\t\t\t\t \t\t\t\t \t \t \t\t\t\t\t \t \t \t \t \t \t \t\t \t\t\t \t \t\t\t\t\t\t \t\t \t \t \t\t \t \t\t \t \t\t\t \t \t\t\t\t\t\t \t \t\t\t\t \t\t\t\t \t\t\t \t\t\t \t \t \t\t\t\t \t\t \t\t\t \t\t\t \t\t\t \t\t\t \t\t \t \t \t\t\t \t \t \t\t \t \t \t \t \t \t\t \t \t \t\t\t\t \t \t\t \t \t\t \t \t \t \t\t \t\t \t\t \t\t\t \t\t\t \t\t\t \t \t\n \t \t\t\t\t\t \t\t \t \t \t \t \t\t\t \t \t \t\t \t \t \t\t\t\t \t\t \t\t \t \t \t\t\t \t\t\t\t \t\t\t \t \t \t \t\t\t \t\t\t\t \t \t\t \t \t \t\t\t\t \t \t \t\t \t \t\n \n \n \n \t \t\n\n \t\n \n \t\t\t\t \t \n\t \t\t\t\n \t\t\t\t \t \n\t \t \n \t\t\n\t \n\n\t\t\t\n \n\n\n\t \t\n \t \t \n\n \t\n \t \t\n\n \t \n \t \n\n \t\n\n \t \n\n \t\n\t\n \t \t \n\n \t\n\n\n\n\n \n \n \n \n \t\n\n \t\n\n \n \n \n\t \n \n \t \n\t \t\t \n\t \t \n\t \t \n \t \n\n \n \n \t\t\n\t \t\t \t\t \t\t\t\n\t \n \t\t\t \n\t \t\t \t \n\t \t\n \t\t\n\t \t \n \t\t\n\t \n\n\t\t\n \n\n\n\t\n0\n