diff options
author | Yusuke Endoh <[email protected]> | 2023-02-26 00:06:24 +0900 |
---|---|---|
committer | Yusuke Endoh <[email protected]> | 2023-02-27 11:20:42 +0900 |
commit | b6704201a3ef6a7f07da8d4ca82499710a3eea10 (patch) | |
tree | a674b31db7c5ed73aa2172690bba4c0a7f3a3040 /sample/all-ruby-quine.rb | |
parent | 2535b1819f910f0e12bf609c72e45f7230a060c9 (diff) |
Add all-ruby-quine as a sample code
This sample code works on all release versions of Ruby, from Ruby 0.49.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7380
Diffstat (limited to 'sample/all-ruby-quine.rb')
-rw-r--r-- | sample/all-ruby-quine.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/sample/all-ruby-quine.rb b/sample/all-ruby-quine.rb new file mode 100644 index 0000000000..7686121468 --- /dev/null +++ b/sample/all-ruby-quine.rb @@ -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)# |