2010年09月05日
The Qlobe
My Quines are sometimes specialized for Japanese. But to attend RubyConf, I should write "global" Quines.
v=0000;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC "%.#% :::##" 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B "##% ::##########" O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? "##: ###############" g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W "# #. .####:#######" lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. " ##### # :############" R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 " #######################" 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ " ############:#### %#####" EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q " .#############:##% .## ." /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; " %% .################. #. " ;s="v=%04o;ev"%
(;v=(v-($*+[45, ":####: :##############% : " ])[n=0].to_i;)%
360)+"al$s=%q#{ "%######. ######### " ;;"%c"%126+$s<<
126}";d.gsub!(/ "##########. #######% " |\s|".*"/,"");;
require"zlib"|| "########### :######. " ;d=d.unpack"C*"
d.map{|c|n=(n|| ":#########: .######: . " )*90+(c-2)%91};
e=["%x"%n].pack " :#######% :###### #: " &&"H*";e=Zlib::
Inflate.inflate( " ######% .####% :: " &&e).unpack("b*"
)[0];22.times{|y| " ####% %### " ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(; " .###: .#% " ;2))*23).floor;(w*
2-1).times{|x|u=(e+ " %## " )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[( " #. " ;y*80)+120-w+x]=(""<<
32<<".:%#")[4*u.count(( " . " ;"0"))/u.size]}};;puts\
s+";_ The Qlobe#{" "*18+ ( "# :#######" ;"Copyright(C).Yusuke End\
oh, 2010")}";exit~;_ The Qlobe Copyright(C).Yusuke Endoh, 2010
This quine turns 45 degrees when executed; thus, it will come around when executed eight times (see below). You can make it any-degree turn by giving an integer as an command-line argument.
v=0416;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC ".#####%.#% " 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B " .#####%##% :" O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? " #####%###: #" g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W " %######## #." lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. " :####### ###" R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 " ###: : ####" 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ " %#... #####" EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q " %### .#####" /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; " :. %% .#####" ;s="v=%04o;ev"%
(;v=(v-($*+[45, " :####: :####" ])[n=0].to_i;)%
360)+"al$s=%q#{ " %######. " ;;"%c"%126+$s<<
126}";d.gsub!(/ " ##########. " |\s|".*"/,"");;
require"zlib"|| " ########### " ;d=d.unpack"C*"
d.map{|c|n=(n|| " :#########: " )*90+(c-2)%91};
e=["%x"%n].pack " :#######% " &&"H*";e=Zlib::
Inflate.inflate( " ######% " &&e).unpack("b*"
)[0];22.times{|y| " ####% " ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(; " .###: " ;2))*23).floor;(w*
2-1).times{|x|u=(e+ " %## " )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[( " #. " ;y*80)+120-w+x]=(""<<
32<<".:%#")[4*u.count(( " . " ;"0"))/u.size]}};;puts\
s+";_ The Qlobe#{" "*18+ ( " .##### :#" ;"Copyright(C).Yusuke End\
oh, 2010")}";exit~;_ The Qlobe Copyright(C).Yusuke Endoh, 2010
v=0341;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC "#% .#####%." 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B " : %#####%##. " O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? " #####%###: " g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W " %######## " lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. " :####### " R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 " :### : " 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ " %#... " EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q " .###: " /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; " :. %% " ;s="v=%04o;ev"%
(;v=(v-($*+[45, " :####: " ])[n=0].to_i;)%
360)+"al$s=%q#{ " %######. " ;;"%c"%126+$s<<
126}";d.gsub!(/ " ##########" |\s|".*"/,"");;
require"zlib"|| "% ##########" ;d=d.unpack"C*"
d.map{|c|n=(n|| " :#########" )*90+(c-2)%91};
e=["%x"%n].pack " ########" &&"H*";e=Zlib::
Inflate.inflate( "#. ######%" &&e).unpack("b*"
)[0];22.times{|y| "## :####. " ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(; "#. .###: " ;2))*23).floor;(w*
2-1).times{|x|u=(e+ "% . %## " )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[( " . #. " ;y*80)+120-w+x]=(""<<
32<<".:%#")[4*u.count(( " : " ;"0"))/u.size]}};;puts\
s+";_ The Qlobe#{" "*18+ ( "#. .##### " ;"Copyright(C).Yusuke End\
oh, 2010")}";exit~;_ The Qlobe Copyright(C).Yusuke Endoh, 2010
v=0264;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC "####% .####" 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B "##### : .#####" O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? "######. #####%" g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W "####: . %######" lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. "#### . :######" R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 "####% ###: " 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ "### %#..." EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q "## .. %###" /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; ":#. . :" ;s="v=%04o;ev"%
(;v=(v-($*+[45, ": : : " ])[n=0].to_i;)%
360)+"al$s=%q#{ "% %#: " ;;"%c"%126+$s<<
126}";d.gsub!(/ "#::#.: %#% " |\s|".*"/,"");;
require"zlib"|| " : :#% " ;d=d.unpack"C*"
d.map{|c|n=(n|| " :% : " )*90+(c-2)%91};
e=["%x"%n].pack " %###%% " &&"H*";e=Zlib::
Inflate.inflate( " ########. " &&e).unpack("b*"
)[0];22.times{|y| " ########. " ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(; " ##:%###. " ;2))*23).floor;(w*
2-1).times{|x|u=(e+ " %% . " )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[( " . " ;y*80)+120-w+x]=(""<<
32<<".:%#")[4*u.count(( " " ;"0"))/u.size]}};;puts\
s+";_ The Qlobe#{" "*18+ ( "####. .###" ;"Copyright(C).Yusuke End\
oh, 2010")}";exit~;_ The Qlobe Copyright(C).Yusuke Endoh, 2010
v=0207;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC "#######% .#" 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B "##########: : " O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? "#############. " g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W "############: . " lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. "############# . " R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 "############## " 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ "# %######### " EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q " %#: %##: : " /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; " #. .:#. . " ;s="v=%04o;ev"%
(;v=(v-($*+[45, " : : : : " ])[n=0].to_i;)%
360)+"al$s=%q#{ " :% %#: " ;;"%c"%126+$s<<
126}";d.gsub!(/ " #::#.: %#% " |\s|".*"/,"");;
require"zlib"|| " : :#% " ;d=d.unpack"C*"
d.map{|c|n=(n|| " :% : " )*90+(c-2)%91};
e=["%x"%n].pack " .###%# " &&"H*";e=Zlib::
Inflate.inflate( " ########. " &&e).unpack("b*"
)[0];22.times{|y| " :######## " ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(; " ##:%###. " ;2))*23).floor;(w*
2-1).times{|x|u=(e+ " %% . " )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[( " . " ;y*80)+120-w+x]=(""<<
32<<".:%#")[4*u.count(( " " ;"0"))/u.size]}};;puts\
s+";_ The Qlobe#{" "*18+ ( "#######. ." ;"Copyright(C).Yusuke End\
oh, 2010")}";exit~;_ The Qlobe Copyright(C).Yusuke Endoh, 2010
v=0132;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC ":::#######%" 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B "################ : " O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? "####################. " g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W " .####:############: . " lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. "# # :################# . " R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 "#######################% " 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ "######:#### %######### " EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q "#######:##% .## .### .. " /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; "##########. #. .:#. . " ;s="v=%04o;ev"%
(;v=(v-($*+[45, "#########% : : : : " ])[n=0].to_i;)%
360)+"al$s=%q#{ "######### :% %#: " ;;"%c"%126+$s<<
126}";d.gsub!(/ "#######% #::#.: %#% " |\s|".*"/,"");;
require"zlib"|| ":######. : :#% " ;d=d.unpack"C*"
d.map{|c|n=(n|| ".######: . :% : " )*90+(c-2)%91};
e=["%x"%n].pack ":###### #: %###%% " &&"H*";e=Zlib::
Inflate.inflate( ".####% :: ########. " &&e).unpack("b*"
)[0];22.times{|y| " %### ########. " ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(; " .#% ##:%###. " ;2))*23).floor;(w*
2-1).times{|x|u=(e+ " %% . " )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[( " . " ;y*80)+120-w+x]=(""<<
32<<".:%#")[4*u.count(( " " ;"0"))/u.size]}};;puts\
s+";_ The Qlobe#{" "*18+ ( "##########." ;"Copyright(C).Yusuke End\
oh, 2010")}";exit~;_ The Qlobe Copyright(C).Yusuke Endoh, 2010
v=0055;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC "% :::#####" 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B " .:################" O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? " ######################" g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W " #. .####:############: " lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. " ##### # :################# . " R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 " :############################ " 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ " ############:#### %######### " EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q " %############:### %#: %##: : " /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; " .################. #. .:#. . " ;s="v=%04o;ev"%
(;v=(v-($*+[45, " :##############% : : : : " ])[n=0].to_i;)%
360)+"al$s=%q#{ " ######### :% %#: " ;;"%c"%126+$s<<
126}";d.gsub!(/ " #######% #::#.: %#" |\s|".*"/,"");;
require"zlib"|| " :######. : :" ;d=d.unpack"C*"
d.map{|c|n=(n|| " .######: . :% " )*90+(c-2)%91};
e=["%x"%n].pack " ######%:# .###%" &&"H*";e=Zlib::
Inflate.inflate( " .####% :: ######" &&e).unpack("b*"
)[0];22.times{|y| " .###: :#####" ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(; " .#% ##:%#" ;2))*23).floor;(w*
2-1).times{|x|u=(e+ " " )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[( " " ;y*80)+120-w+x]=(""<<
32<<".:%#")[4*u.count(( " " ;"0"))/u.size]}};;puts\
s+";_ The Qlobe#{" "*18+ ( ":##########" ;"Copyright(C).Yusuke End\
oh, 2010")}";exit~;_ The Qlobe Copyright(C).Yusuke Endoh, 2010
v=0000;eval$s=%q~d=%!^Lcf<LK8, _@7gj*LJ=c5nM)Tp1g0%Xv.,S[<>YoP
4ZojjV)O>qIH1/n[|2yE[>:ieC "%.#% :::##" 97N-A&Kj_K_><wS5rtWk@*a+Y5
yH?b[F^e7C/56j|pmRe+:)B "##% ::##########" O98(Zh)'Iof*nm.,$C5Nyt=
PPu01Avw^<IiQ=5$'D-y? "##: ###############" g6`YT+qLw9k^ch|K'),tc
6ygIL8xI#LNz3v}T=4W "# #. .####:#######" lL27FZ0ij)7TQCI)P7u
}RT5-iJbbG5P-DHB<. " ##### # :############" R,YvZ_rnv6ky-G+4U'
$*are@b4U351Q-ug5 " #######################" 00x8RR%`Om7VDp4M5
PFixrPvl&<p[]1IJ " ############:#### %#####" EGgDt8Lm#;bc4zS^
y]0`_PstfUxOC(q " .#############:##% .## ." /,}.YOIFj(k&q_V
zcaAi?]^lCVYp!; " %% .################. #. " ;s="v=%04o;ev"%
(;v=(v-($*+[45, ":####: :##############% : " ])[n=0].to_i;)%
360)+"al$s=%q#{ "%######. ######### " ;;"%c"%126+$s<<
126}";d.gsub!(/ "##########. #######% " |\s|".*"/,"");;
require"zlib"|| "########### :######. " ;d=d.unpack"C*"
d.map{|c|n=(n|| ":#########: .######: . " )*90+(c-2)%91};
e=["%x"%n].pack " :#######% :###### #: " &&"H*";e=Zlib::
Inflate.inflate( " ######% .####% :: " &&e).unpack("b*"
)[0];22.times{|y| " ####% %### " ;w=(Math.sqrt(1-(
(y*2.0-21)/22)**(; " .###: .#% " ;2))*23).floor;(w*
2-1).times{|x|u=(e+ " %## " )[y*z=360,z]*2;u=u[
90*x/w+v+90,90/w];s[( " #. " ;y*80)+120-w+x]=(""<<
32<<".:%#")[4*u.count(( " . " ;"0"))/u.size]}};;puts\
s+";_ The Qlobe#{" "*18+ ( "# :#######" ;"Copyright(C).Yusuke End\
oh, 2010")}";exit~;_ The Qlobe Copyright(C).Yusuke Endoh, 2010
translated from mamememo in Japanese (2010年09月05日).
Subscribe to:
Post Comments (Atom)
35 comments:
This is awe-inspiring. Thank you.
Reply DeleteYou are a mad man. You are completely insane.
Reply DeleteVery, very impressive. Wow.
WOW.
Reply DeleteDo you accept worshipers?
Reply DeleteYou rock! Never seen a better quine.
Reply DeleteWO. AW. WOAW.
Reply DeleteI get a syntax error in line 1 about the token ')',i don't have much knowledge of ruby,but i want to experience this amazing program,can someone help me?
Reply DeleteCrane: What version of ruby are you using? I tested it with ruby 1.8.7-p72 and 1.9.2-p0.
Reply DeleteI tried it with ruby 1.9.1p378
Reply Deletethe total error message is:
./earthrotate.rb: line 1: syntax error near unexpected token `)'
./earthrotate.rb: line 1: `v=0000;eval$s=%q~d=%!^LcfYoP'
Crane: I was able to get past this by using ruby to execute the script. So use:
Reply Delete$ ruby earthrotate.rb
instead of:
$ ./earthrotate.rb
@Justin:I tried as what you said:
Reply Deleteruby earthrotate.rb
and I get this:
earthrotate.rb:12:in `eval': (eval):7: syntax error, unexpected $undefined (SyntaxError)
zcaAi?]^lCVYp!; " %% .###% " |\s|".*"/,"");;
^
(eval):7: syntax error, unexpected ','
zcaAi?]^lCVYp!; " %% .###% " |\s|".*"/,"");;
^
from earthrotate.rb:12:in `main'
1. Copy one of the above programs as a.rb.
Reply Delete2. Run:
while true; do clear; ruby a.rb | tee b.rb; sleep 1; mv -f b.rb a.rb; done
JAWDROP
This has convinced me to write my first blog comment. That is incredible.
Reply DeleteWhen I wrote and thought up my first quine I thought that was pretty impressive, however you have completely blown my mind with this one. That is the single most amazing quine that I have ever seen.
Reply DeleteOh, and for those of you that want to see it in action:
Reply Delete$ watch -n1 'ruby current.rb | tee next.rb && mv next.rb current.rb'
I've made a YouTube video for those who want to see it in action:
Reply Deletehttp://www.youtube.com/watch?v=ktq-22iq-Po
Crazy!
Reply DeleteKeep it up!
Any chance on having a writeup on it's logic?
Please read the source code :-)
Reply Deletedead Anonymous 2 up: quininess is achieved by having most of the program in a string and evaling it. the only exceptions are the v variable and the eval statement itself. v contains the angle of rotation of the globe at a given moment.
Reply Deletefully half of the program is a compressed map of the earth, which is unpacked, and as each line is printed, the corresponding line of the globe is rotated according to the value in v and distorted to proper shape by a lot of Math™, converted to ascii by a simple map, and printed in the correct area. A lot of tricks are used to make sure said area does not get executed as code or stored as data. Hope this helps in your own parsing of the source.
qlobe.ruby:24: warning: parenthesize argument(s) for future version
Reply Deleteruby 1.8.1
although it does work perfectly... just gives a warning.
i've never coded in ruby so i have no idea what the heck that warning means.
that is one AWESOME quine you've built
always had doubts if GOD existed. now i noe He's called Yusuke Endoh.
Reply DeleteHi, I don't know Ruby at all,but I am very much interested in enjoying this piece or your work :) I tried your code on http://ideone.com/sNY7M but as you could see it's giving compilation error.
Reply DeleteFor those wondering how to view this:
Reply Delete1. copy contents of textarea to qlobe.rb
2. for ((;;)); do for i in {1..45}; do clear; ruby qlobe.rb $i; sleep 0.1; done; done
Not sure if the "45" is correct...
It should be 360, not 45. If it's 45 it will only rotate 45° and then start again. So the command should be:
Reply Deletefor ((;;)); do for i in {1..360}; do clear; ruby qlobe.rb $i; sleep 0.1; done; done
Holy shi..quine.
Reply Deletefor i in {0..360}; do clear; ruby qlobe.rb $i; sleep 0.05; done
Reply Delete@Greg, can you script that to run infinitely? I'm not sure how to wrap your script is an infinite do loop.
Reply Deletegot it.
Reply DeleteInfinite loop:
being; for i in {0..360}; do clear; ruby qlobe.rb $i; sleep 0.05; done; end while true;
scratch that, doesn't work right, lemme know if any of you figure it out.
Reply Deletefor (( i=0 ; ; i++ )) do clear; ruby qlobe.rb $i%360; sleep 0.05; done
Reply DeleteThis is amazing.
Reply DeleteManaged to avoid flickering using the following:
Reply Deleteclear; for ((;;)); do for i in {1..360}; do tput cup 0 0; ruby qlobe.rb $i; sleep 0.1; done; done;
Amazing.
Reply DeleteAwesome...
Reply DeleteI do not know whether it's just me or if everybody else encountering problems with your site. It looks like some of the written text in your content are running off the screen. Can someone else please provide feedback and let me know if this is happening to them as well? This might be a problem with my internet browser because I've had this happen previously. Many thanks
Reply Delete