mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Add all-ruby-quine as a sample code
This sample code works on all release versions of Ruby, from Ruby 0.49.
This commit is contained in:
parent
2535b1819f
commit
b6704201a3
Notes:
git
2023-02-27 02:21:01 +00:00
2 changed files with 56 additions and 0 deletions
24
sample/all-ruby-quine.rb
Normal file
24
sample/all-ruby-quine.rb
Normal file
|
@ -0,0 +1,24 @@
|
|||
eval($s=("t='eval($s=('+d=34.chr;s=3
|
||||
2.chr+$s*i=8;v=$VERSION||eval('begin;v=V
|
||||
ERSION;rescue;v||RUBY_VERSION;end');f=('?'*8
|
||||
+'A|'+'?'*20+'G?c'+'?'*15+'A@CXx@~@_`OpGxCxp@~pO
|
||||
xS|O~G?c?q?xC`AP|q?x_|C_xC_xO@H@cG?G?qA|_|_`GCpOxC|H
|
||||
NFccqq@`_|OF@`?q?x_@x_x_`GB`O``O~G?C@qCxCxP@D@|G~C?pO|C?
|
||||
pO|C?AP|A~HNN`ccxC|Q@L@B"+"GpGpc@p?x_`GB`???_@FO|OB@
|
||||
xC|P`@?c?q?HPx@~@_`G@`????@L^`?q?x?xq@|_|O~GC`
|
||||
xA~@_@GBD').unpack('c*');w=4+v.length*u=
|
||||
15;r=10.chr;j=0;while-24+w*u>i=1+i
|
||||
;x=i%w;x>0||t=t+d+'+'+r+d;k=
|
||||
i/w%12>2&&x%u>3&&x%u+i
|
||||
/w*11-34+('-._'.
|
||||
index(c=v[
|
||||
x/u,1]
|
||||
)||c.hex +3)*99|
|
||||
|0; k=f [k/6 ][k%
|
||||
6]; t=t +s[
|
||||
k*j =k+ j,1
|
||||
]end;pr int (t+
|
||||
d+' ).s pli
|
||||
t.j oin [0,
|
||||
609 ])# Y.E. '+r)
|
||||
").split .join)#
|
Loading…
Add table
Add a link
Reference in a new issue