Hatena::ブログ(Diary)

まめめも このページをアンテナに追加 RSSフィード

2009-11-30

[] 山手 quine

t="+,m-n./mAm0o1p23a4q56r7sBt89u-t-1:v;A<w4x=y1z>[?]A^@CD_
CD_EsF`GHmIJbKa*l";eval$s=%w{F=%q{ceY8#<DvO1=x&t9CSOqMYkzH
U.kCpz+Vo8hB.1AF&tq21+$/IrMY]U.aDd!-1y!4MMGQm6m?bYh($QMYpX
s4g,x1UlbNKH?>NzbisMn?sT@m3,F.Abb`xW!r%'%Ybee>xkUfjf[(*^Nd
Xo_"@hQh%Fx*q[iB7EM"suSG8GVOIzceg/O=4CL,d[-k]twgVP`&wcfaT`
2M)j8sFY?(HKzOrVCHO_694[Uq8g  @i/i;tMBG#;-;B]rV[])`3'<os^.
OV(SA<=ok%m[iV#qt[&dJ7SIdB;/  VUnVIrH;hEJ*QWD"E+5)gfrmD"#E
XlNVv1j)^^                                      bCi_gw+s-V
J<?fWdtbnxRgJm4J.yHO_ay2e%rc  Tj]ALVU'`V=]]W;x&9MP&g5zAVHR
?B,SZA+!_[0f!TUCv$Hin?-G7hAL  BW6w1x+F#%@FZ<7!9;vNxsj6HW_O
Ao)H5cv`Ves-BQ"Z                          =K$_[o]Can(;1cJp
HV<:4x2,AnZgqvsy  >VWDZdF-+^  46Z^Z@<>1<  cJ3E4GYSqGg7$ocX
88=*`RVO*WskDY-#  uj$t3$XP#U  IH]regXHa_  >sta`lbL+=J3sL3e
BYxm/a0]lV1?M4WA                          u7jCGk`UBzB#*gOJ
wHu#gQst^XB0VXjT  imG<qb[s!*  S#":,frD+N  wn=nI<u;#dw*Y?"8
B#G[%YT$mvLd<gUd  lN^6#bZX$S  a#owd125V!  4d+zL5)I;JD-ToJ"
uN?h9Braq+dG4Nr[                          ynH,hS?nk4JD^/.q
KS&kW@(62e]xb0j2(;4X[ROR2W      Ifjf^3vhJ5jb5"sJ(4b6Ek1?Vx
%s$^.yD.SY$':h[zd$D7o$n:  Zp  F=  2bHENRzBQhsd_7Im*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Jca  5&Z0K'r[o,K*"/^jv6
m08,PTZy$g?eX[aN4j  J]AkXcV72;!};f=0;F  .unpack("C*").map{
|c|f=f*89+((c-2)%9                      0-1)};require'zlib
';t=t.split*"";$*[0]?(t[/([*  -K]+.)([*-K]+.)$/];t=$2+$`+s
=$1):(s=t[/.+?[L-z]/];t=$'+s  );f=Zlib::Inflate.inflate(Ma
rshal.dump(f)[7..-1]  );S=%{  t="#    {t}";eval$s=%w{#$s}*
"";%|}+F*9;P=proc{pu  ts(S.s  lice!(0,  58));P};P[][][][s.
upcase.unpack("C*"  ).map{|c  |c-=c>92?4  3:42;;P[][][20.t
imes{|n|puts(("%  029b"%("\0  "+f[60*c+3*n  ,3]).unpack("N
")[0]).gsub(    /./){$&<"1"?  (S.slice!(0,2)  ):(32.chr*2)
})}]}][];puts(*["+"+"-"*      25,"|,##,(c),Yusuke,Endoh,20
09".split(",").join(32.chr)].map{|l|S.slice!(0,32)+l})}*""
;%|ceY8#<DvO1=x&t9CSOqMYkzHU.kCpz+Vo8hB.1AF&tq21+$/IrMY]U.
aDd!-1y!4MMGQm6m?bYh($QMYpXs4g,x1UlbNKH?>NzbisMn?sT@m3,F.A
bb`xW!r%'%Ybee>xkUfjf[(*^NdXo_"@+-------------------------
hQh%Fx*q[iB7EM"suSG8GVOIzceg/O=4| ## (c) Yusuke Endoh 2009

外回り。実行するたびに東京→有楽町→新橋→浜松町→...と進んで行って、以下で 1 周します。

$ cat yamanote-quine-clockwise.rb  | ruby | ruby | ruby | ruby | ruby |
  ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby |
  ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby |
  ruby | ruby | ruby | ruby

t="+a,-b./m0n1o23p423pAq5r6s7t8u9v:A;w<7=x<y>?zBy@oCD[9]EF
a7^G_AmHIm<`JKm*l";eval$s=%w{F=%q{_gE$XA/OdSUccTE&K%1BhzY]
dT@p;(Zy7x>O?2Vqd^lQ6$S:$$v2Bqg:l5KFc:Z?Sgh055/ZPH%g8jp/1?
2AAlyzxRf+zR+(ybWR0K.A@MZ[_vSd=7jn#-(:DT[#:^ffre&c1=.+'AuD
.pe[kKEtOajpw1:@R-,N'Pdfi(U%]mAJtx8UhT0WX&Ke&qI`@;0DDlHnut
Tz)bK3_Dv99VF2AH&)l@yqEpFh+i  fqhzj2^uDpTQ5eV*Xjz^(MfX&[H+
kl6i$fQ9n>@RzAkTt$ze(N:cVn]A  m@[Bv=nRa_+i8s^s+')ymY$Qk4H^
hE$cra[:jm                                      (e2@@4]2^'
)]</kbOuQsW8bCr<b^&?*#b,4"CW  7(o,5Ig?<_=Jai514vJdx<D*7z3m
RiFm$LCCQ8KU(6)ccFDV;m3wr5@<  gl!61rhG,dtTv'%ng*Jo6T[#>ae>
3Me1awZTb1]sq;r+                          U6OFy`5SHF/pCi0;
k6z?kK[#&I'jDyHN  ML;.^/l4/R  O/(EHb:n]8  b8Ea1dlbEAZ"RLaj
(s35<*%whxPc1QAz  dVzOo>.pvo  Q=d2mHCs(K  l9ruq,u/IcVU:UH5
)6%t"2w?x9az&0pz                          ,mNX5`d"(e0eW%-=
QJZFC6_11z:`q810  rIl)(.:BGS  C2'&20Yoxe  N5H@.'Ui%>*u_ub@
?Z4#SIM*u5dLBq/F  U.'GKJLh+$  B]b1&#9xk5  ^*JB8%qZxQxW9:-V
:9i(TQr56o/H'/Z0                          +oYK!v?@kW$.1*xw
l'$%VM8sP3LtsCp0HU30[B_H>r      K>Z9E[[rjt-?](bnL'C#=1V@%,
T#eX]?I?G?grpx6Gb=by[>h2  83  tj  Kh$1,CkWL!M9oB=l[=4#ef`f
dDJ9FHhm>8e5nGfR69>V72  t3:`  kQ!B  k3fu<Q0!"C(yf4Lc'hD4al
k(#7*u%_A)s"c_)I-#5l  >S19>7  rn.Aq`  uWMVFg+-P":wX'W^%':r
of+yMuw21eXeu:seO[  `4+lasA&  #gq&q,2V  saP]@rQ"![_UHVL$?!
r4sJk6G183Zo)b    +Wz@#;`"O4  _KBQg!25an    9)(rG+YP1A>0D0
Oj;k]c]9c/    ;^'Z9GsJnOQ!-j  t7*,_=SG[iaA-f    t?'JEgyg1>
#!n.+zq&fWY2bbe$35btjzYIQU+w  *s?56)Z]!CR1ESw7hx<1gw_Z4-qW
puvW!HWkep3Jei=bT'W)$>0W-aa?OZ#^D1B&F;gH8Y0x&u#i"T7kcPmimm
>!"7,t6e7BF8g.eUyge1=BsQvQ^<vPf_P^A`%Bs2W"cMd!,5#,oFlAdJW:
j=&$z!Zk=llXi>2za%L0j;e).VYc:k1F_V(#:&"(nGeO$ZNP00"*9A).$?
+@Sv$ouzxmF]Q6L:"%/*Z3o?Q4Qi  4x@h]Dw/p=d^8y2qQf,jL5N0Dqe2
0pBq6Aqnc-x>,%f+0u%KrpKRmIZ/  jnu*dI]%/$)@[fW&MMjJ;]Eai?[y
#9d3#UQ/uvriVjZ&N@&i3`fE_uZY  v?g^E;]55sO6G`2/!F>zQ;NBiO5r
U@Ta06?dsI                                      Sd5d1(xK0m
6:+v'304'"4N9rWq06GDcVX-@``=iT+y$ZE8zv!;jH:2=.zef5qm@/?-7.
d1YXA):7(O1g;nI/5fJ@eVunUR]9DZOUEa(21lMp@n1C@v;CjkNN#(p;^:
T#6Uv!_7)bB7U-Da5g                      Dz4$bgFe"wc*G>^-`u
tV8T]c;9fRFSQi$)xG  hidObu[-YKdTxDOG=^  U)>j""r&,oUz.7@TB(
].bkjPDyg>EqW"*[xL  b'TyvrT9P=/0a._kz^  Spo62npNX1)DybpTF1
L1rXIM^ac%(,-$XcA`  ;LkYTOY9&"=Az):6<D  [5b(`JkE.g59LEJz,J
_XUE96HXg*J'@d])Bw  %H?aBwkQ?]};f=0;F.  unpack("C*").map{|
c|f=f*89+((c-2)%90                      -1)};require'zlib'
;t=t.split*"";$*[0]?(t[/([*-  K]+.)([*-K]+.)$/];t=$2+$`+s=
$1):(s=t[/.+?[L-z]/];t=$'+s)  ;f=Zlib::Inflate.inflate(Mar
shal.dump(f)[7..-1])  ;S=%{t  ="#{    t}";eval$s=%w{#$s}*"
";%|}+F*9;P=proc{put  s(S.sl  ice!(0,5  8));P};P[][][][s.u
pcase.unpack("C*")  .map{|c|  c-=c>92?43  :42;P[][][20.tim
es{|n|puts(("%02  9b"%("\0"+  f[60*c+3*n,3  ]).unpack("N")
[0]).gsub(/.    /){$&<"1"?(S  .slice!(0,2)):  (32.chr*2)})
}]}][];;;puts(*["+"+"-"*      25,"|,##,(c),Yusuke,Endoh,20
09".split(",").join(32.chr)].map{|l|S.slice!(0,32)+l})}*""
;%|_gE$XA/OdSUccTE&K%1BhzY]dT@p;(Zy7x>O?2Vqd^lQ6$S:$$v2Bqg
:l5KFc:Z?Sgh055/ZPH%g8jp/1?2AAlyzxRf+zR+(ybWR0K.A@MZ[_vSd=
7jn#-(:DT[#:^ffre&c1=.+'AuD.pe[k+-------------------------
KEtOajpw1:@R-,N'Pdfi(U%]mAJtx8Uh| ## (c) Yusuke Endoh 2009

こっちは内回り。

$ cat yamanote-quine-counter-clockwise.rb | ruby | ruby | ruby | ruby |
  ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby |
  ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby | ruby |
  ruby | ruby | ruby | ruby | ruby

どちらもオプションを与えると逆方向に進みます。

$ ruby yamanote-quine-clockwise.rb rev

1.8.6-p243 、1.8.7-p72 、1.9.1-p243 、trunk くらいで動作確認しました。

スパム対策のためのダミーです。もし見えても何も入力しないでください
ゲスト


画像認証