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日).

label:

35 comments:

  1. This is awe-inspiring. Thank you.

    Reply Delete
  2. You are a mad man. You are completely insane.

    Very, very impressive. Wow.

    Reply Delete
  3. Do you accept worshipers?

    Reply Delete
  4. You rock! Never seen a better quine.

    Reply Delete
  5. WO. AW. WOAW.

    Reply Delete
  6. I 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 Delete
  7. Crane: What version of ruby are you using? I tested it with ruby 1.8.7-p72 and 1.9.2-p0.

    Reply Delete
  8. I tried it with ruby 1.9.1p378
    the total error message is:
    ./earthrotate.rb: line 1: syntax error near unexpected token `)'
    ./earthrotate.rb: line 1: `v=0000;eval$s=%q~d=%!^LcfYoP'

    Reply Delete
  9. Crane: I was able to get past this by using ruby to execute the script. So use:

    $ ruby earthrotate.rb

    instead of:

    $ ./earthrotate.rb

    Reply Delete
  10. @Justin:I tried as what you said:
    ruby 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'

    Reply Delete
  11. 1. Copy one of the above programs as a.rb.

    2. Run:

    while true; do clear; ruby a.rb | tee b.rb; sleep 1; mv -f b.rb a.rb; done

    JAWDROP

    Reply Delete
  12. This has convinced me to write my first blog comment. That is incredible.

    Reply Delete
  13. When 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 Delete
  14. Oh, and for those of you that want to see it in action:
    $ watch -n1 'ruby current.rb | tee next.rb && mv next.rb current.rb'

    Reply Delete
  15. I've made a YouTube video for those who want to see it in action:

    http://www.youtube.com/watch?v=ktq-22iq-Po

    Reply Delete
  16. Crazy!
    Keep it up!

    Any chance on having a writeup on it's logic?

    Reply Delete
  17. Please read the source code :-)

    Reply Delete
  18. dead 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.

    fully 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.

    Reply Delete
  19. qlobe.ruby:24: warning: parenthesize argument(s) for future version

    ruby 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

    Reply Delete
  20. always had doubts if GOD existed. now i noe He's called Yusuke Endoh.

    Reply Delete
  21. Hi, 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 Delete
  22. For those wondering how to view this:

    1. 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...

    Reply Delete
  23. It should be 360, not 45. If it's 45 it will only rotate 45° and then start again. So the command should be:

    for ((;;)); do for i in {1..360}; do clear; ruby qlobe.rb $i; sleep 0.1; done; done

    Reply Delete
  24. Holy shi..quine.

    Reply Delete
  25. for i in {0..360}; do clear; ruby qlobe.rb $i; sleep 0.05; done

    Reply Delete
  26. @Greg, can you script that to run infinitely? I'm not sure how to wrap your script is an infinite do loop.

    Reply Delete
  27. got it.
    Infinite loop:

    being; for i in {0..360}; do clear; ruby qlobe.rb $i; sleep 0.05; done; end while true;

    Reply Delete
  28. scratch that, doesn't work right, lemme know if any of you figure it out.

    Reply Delete
  29. for (( i=0 ; ; i++ )) do clear; ruby qlobe.rb $i%360; sleep 0.05; done

    Reply Delete
  30. Managed to avoid flickering using the following:

    clear; for ((;;)); do for i in {1..360}; do tput cup 0 0; ruby qlobe.rb $i; sleep 0.1; done; done;

    Reply Delete
  31. Amazing.

    Reply Delete
  32. I 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

Subscribe to: Post Comments (Atom)

AltStyle によって変換されたページ (->オリジナル) /