编写一个产生其自身镜像的程序。一个例子就是奇妙的骆驼代码,它读取自己的代码并生成两个较小的2x2版本。给定输入:
$_='ev
al("seek\040D
ATA,0, 0;");foreach(1..3)
{<DATA>;}my @camel1hump;my$camel;
my$Camel ;while( <DATA>){$_=sprintf("%-6
9s",$_);my@dromedary 1=split(//);if(defined($
_=<DATA>)){@camel1hum p=split(//);}while(@dromeda
ry1){my$camel1hump=0 ;my$CAMEL=3;if(defined($_=shif
t(@dromedary1 ))&&/\S/){$camel1hump+=1<<$CAMEL;}
$CAMEL--;if(d efined($_=shift(@dromedary1))&&/\S/){
$camel1hump+=1 <<$CAMEL;}$CAMEL--;if(defined($_=shift(
@camel1hump))&&/\S/){$camel1hump+=1<<$CAMEL;}$CAMEL--;if(
defined($_=shift(@camel1hump))&&/\S/){$camel1hump+=1<<$CAME
L;;}$camel.=(split(//,"\040..m`{/J\047\134}L^7FX"))[$camel1h
ump];}$camel.="\n";}@camel1hump=split(/\n/,$camel);foreach(@
camel1hump){chomp;$Camel=$_;y/LJF7\173\175`\047/\061\062\063\
064\065\066\067\070/;y/12345678/JL7F\175\173\047`/;$_=reverse;
print"$_\040$Camel\n";}foreach(@camel1hump){chomp;$Camel=$_;y
/LJF7\173\175`\047/12345678/;y/12345678/JL7F\175\173\0 47`/;
$_=reverse;print"\040$_$Camel\n";}';;s/\s*//g;;eval; eval
("seek\040DATA,0,0;");undef$/;$_=<DATA>;s/\s*//g;( );;s
;^.*_;;;map{eval"print\"$_\"";}/.{4}/g; __DATA__ \124
\1 50\145\040\165\163\145\040\157\1 46\040\1 41\0
40\143\141 \155\145\1 54\040\1 51\155\ 141
\147\145\0 40\151\156 \040\141 \163\16 3\
157\143\ 151\141\16 4\151\1 57\156
\040\167 \151\164\1 50\040\ 120\1
45\162\ 154\040\15 1\163\ 040\14
1\040\1 64\162\1 41\144 \145\
155\14 1\162\ 153\04 0\157
\146\ 040\11 7\047\ 122\1
45\15 1\154\1 54\171 \040
\046\ 012\101\16 3\16
3\15 7\143\15 1\14
1\16 4\145\163 \054
\040 \111\156\14 3\056
\040\ 125\163\145\14 4\040\
167\1 51\164\1 50\0 40\160\
145\162 \155\151
\163\163 \151\1
57\156\056
它产生:
JXXXXXXXXL. JXXLm. .mJXXL .JXXXXXXXXL
{XXXXXXXXXXX. JXXXmXXXXm mXXXXmXXXL .XXXXXXXXXXX}
.XXXXXXXXXXXXXL. {XXXXXXXXXF 7XXXXXXXXX} .JXXXXXXXXXXXXX.
JXXXXXXXXXXXXXXXXL.`XXXXXX. .XXXXXX'.JXXXXXXXXXXXXXXXXL
JXXXXXXXXXXXXXXXXXXXmXXXXXXX. .XXXXXXXmXXXXXXXXXXXXXXXXXXXL
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXX} {XXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXF 7XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX'7XXXXXXXXXXXXXXXXXXXXXXXXXF 7XXXXXXXXXXXXXXXXXXXXXXXXXF`XX
XX {XXXFXXXXXXXXXXXXXXXXXXXF' `7XXXXXXXXXXXXXXXXXXX7XXX} XX
`X}{XXX'7XXXFXXXXX^XXXXX `' `' XXXXX^XXXXX7XXXF`XXX}{X'
`'XXX' {XXX'XXXXX 7XXXF 7XXXF XXXXX`XXX} `XXX`'
.XX} {XXF {XXXX}`XXX} {XXX'{XXXX} 7XX} {XX.
{XX `XXL `7XX} 7XX} {XXF {XXF' JXX' XX}
`XX `XXL mXXF {XX XX} 7XXm JXX' XX'
XX 7XXXF `XX XX' 7XXXF XX
XX. JXXXX. 7X. .XF .XXXXL .XX
{XXL 7XF7XXX. {XX XX} .XXXF7XF JXX}
`XXX' `XXXm mXXX' `XXX'
^^^^^ ^^^^^
.mJXXL .JXXXXXXXXL JXXXXXXXXL. JXXLm.
mXXXXmXXXL .XXXXXXXXXXX} {XXXXXXXXXXX. JXXXmXXXXm
7XXXXXXXXX} .JXXXXXXXXXXXXX. .XXXXXXXXXXXXXL. {XXXXXXXXXF
.XXXXXX'.JXXXXXXXXXXXXXXXXL JXXXXXXXXXXXXXXXXL.`XXXXXX.
.XXXXXXXmXXXXXXXXXXXXXXXXXXXL JXXXXXXXXXXXXXXXXXXXmXXXXXXX.
{XXXXXXXXXXXXXXXXXXXXXXXXXXXXX. .XXXXXXXXXXXXXXXXXXXXXXXXXXXXX}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
7XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXF
7XXXXXXXXXXXXXXXXXXXXXXXXXF`XX XX'7XXXXXXXXXXXXXXXXXXXXXXXXXF
`7XXXXXXXXXXXXXXXXXXX7XXX} XX XX {XXXFXXXXXXXXXXXXXXXXXXXF'
`' XXXXX^XXXXX7XXXF`XXX}{X' `X}{XXX'7XXXFXXXXX^XXXXX `'
7XXXF XXXXX`XXX} `XXX`' `'XXX' {XXX'XXXXX 7XXXF
{XXX'{XXXX} 7XX} {XX. .XX} {XXF {XXXX}`XXX}
{XXF {XXF' JXX' XX} {XX `XXL `7XX} 7XX}
XX} 7XXm JXX' XX' `XX `XXL mXXF {XX
XX' 7XXXF XX XX 7XXXF `XX
.XF .XXXXL .XX XX. JXXXX. 7X.
XX} .XXXF7XF JXX} {XXL 7XF7XXX. {XX
mXXX' `XXX' `XXX' `XXXm
^^^^^ ^^^^^
The use of a camel image in association with Perl is a trademark of O'Reilly &
Associates, Inc. Used with permission.
(版权文本是可选的。)
一个更简单的示例将输入:
#######
#
#
######
#
# #
#####
并产生:
##### #####
# # # #
# #
###### ######
# #
# #
####### #######
####### #######
# #
# #
###### ######
# #
# # # #
##### #####
参赛作品应展示艺术。
这是一次人气竞赛,因此,具有最高(最高)投票数的参赛作品将获胜!
目标是仅反映文本的代码,还是必须是适当的字符串?它实际上应该接受输入吗?
—
nitro2k01 2014年
@ nitro2k01应该镜像文本;并没有真正期望它是合适的。不需要用户输入。
—
devnull 2014年
好吧,您的骆驼3和4应该倒过来成为骆驼1和2的镜像!
—
Mukul Kumar 2014年
@MukulKumar只要输出是艺术性的,任何一种形式都可以。
—
devnull 2014年
我认为标题应该更改为“ɟʃǝsuʍosʇıɟosǝƃɐɯıɹoɹɹıɯsʇuıɹdʇɐɥʇoɹԀ”。
—
AJMansfield'3