Slide 1

Slide 1 text

An Invitation to TRICK: How to write weird Ruby programs Yusuke Endoh @ STORES, Inc.

Slide 2

Slide 2 text

This talk

Slide 3

Slide 3 text

What?

Slide 4

Slide 4 text

code.rb $ ruby code.rb No, you have to copy the whole text, from "You don't know" to the end" ';BEGIN{eval$q=%q(def don(e)=e;def You(g)=at_exit{puts"You don'#{g}';BEGIN{eval$q=%q(#$q)};$s=%!#$s!"})};$s=%! puts %(Nb, lbh unir gb pbcl gur jubyr grkg, sebz "Ybh qba'g xabj" gb gur raq").tr("a-z","n-za-m")

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

The abstract You don't know truly weird Ruby yet, do you? TRICK is an irregularly held Ruby programming contest that celebrates the most creative and weird Ruby programs. Among the many submissions, about a dozen particularly exceptional entries are awarded. Curious about what kind of programs win? It is a code like this, this whole text itself. ';BEGIN{eval$q=%q(def don(e)=e;def You(g)=at_exit{puts"You don'#{g}';BEGIN{eval$q=%q(#$q)};$s=%!#$s!"})};$s=%! puts %(Nb, lbh unir gb pbcl gur jubyr grkg, sebz "Ybh qba'g xabj" gb gur raq").tr("a-z","n- za-m") In this talk, we will showcase the winning entries from past TRICK contest and our own weird Ruby code. We will explore various techniques for writing such programs. By the end of this talk, you'll be ready to submit your original Ruby creations to TRICK 2025! This is the abstract for this talk, and IS a Ruby code that prints the code itself

Slide 7

Slide 7 text

Introduction and this talk • Yusuke Endoh (mame, @mametter) – A full-time Ruby committer at STORES, Inc. • Ruby's keyword arguments • Single-line def (as April Fool joke) • TypeProf – A weird Ruby programmer • This talk will – Introduce some weird Ruby programs – Briefly explain the tips to write weird Ruby programs

Slide 8

Slide 8 text

cfp-quine.rb You don't know truly weird Ruby yet, do you? TRICK is an irregularly held Ruby programming contest that celebrates the most creative and weird Ruby programs. Among the many submissions, about a dozen particularly exceptional entries are awarded. Curious about what kind of programs win? It is a code like this, this whole text itself. ';BEGIN{eval$q=%q(def don(e)=e;def You(g)= at_exit{puts"You don'#{g}';BEGIN{eval$q=%q(#$q)};$s=%!#$s!"})};$s=%! puts %(Nb, lbh unir gb pbcl gur jubyr grkg, sebz "Ybh qba'g xabj" gb gur raq").tr("a-z","n- za-m") In this talk, we will showcase the winning entries from past TRICK contest and our own weird Ruby code. We will explore various techniques for writing such programs. By the end of this talk, you'll be ready to submit your original Ruby creations to TRICK 2025!

Slide 9

Slide 9 text

cfp-quine.rb You don't know truly weird Ruby yet, do you? x x TRICK is an irregularly held Ruby programming contest that celebrates the most creative and weird Ruby programs. Among the many submissions, about a dozen particularly exceptional x entries are awarded. x x Curious about what kind of programs win? It is a code like this, this whole text itself. x x ';BEGIN{eval$q=%q(def don(e)=e;def You(g)= at_exit{puts"You don'#{g}';BEGIN{eval$q=%q(#$q)};$s=%!#$s!"})};$s=%! x puts %(Nb, lbh unir gb pbcl gur jubyr grkg, sebz "Ybh qba'g xabj" gb gur raq").tr("a-z","n- za-m") x x In this talk, we will showcase the winning entries from past TRICK contest and our own x weird Ruby code. x We will explore various techniques for writing such programs. x By the end of this talk, you'll be ready to submit your original Ruby creations to TRICK x 2025! A String literal Method calls to "don" and "You": You(don("…")) Quine: printing self

Slide 10

Slide 10 text

Tip: Quine (self-reproducing program) • This program outputs the program itself s=%q( puts "s=%q(#{ s }); eval(s)" ); eval(s) $ ruby quine.rb s=%q( puts "s=%q(#{ s }); eval(s)" ); eval(s)

Slide 11

Slide 11 text

TRICK: A contest for weird Ruby programs mametter eto shinh yhara matz sunleonid flagitious TRICK 2022 Judges Transcendental Ruby Imbroglio Contest for RubyKaigi

Slide 12

Slide 12 text

TRICK: A contest for weird Ruby programs • Four TRICKs held in the past – TRICK 2013 – TRICK 2015 – TRICK 2018 (FINAL) – TRICK 2022 (Returns) • Today, I will pick up only four or five winning entries – All winning entries are published in: No k! http://github.com/tric /

Slide 13

Slide 13 text

TRICK 2022: "Most global" award by mame (me!) a=0132;eval$s=%q!eval(%q~d,h,Y ___---------___ ,X=*$*.map(&:to_i),45;b=(a+d)% R=360;s=[v=[include(Math)]] _--- ---_ ;T=PI*2;n=x=0;f=->{(n/=2)%2 >0?1:f[]*2+(n/=2)%2};g=- _- v@v ,,,,,, -_ >{z=f[];z/2*(3-z%2*6)};" 8'8f'y;I;asr1mY?Sr$6r _- ,vv@@@@@@@^''@v,-_ {+Gi{03G3=ZbpUo3l'}Yw CqxJfHIWd'R /v ,@@@@@@@@@@@v ^^^'''^@@@@\ MUS4&$r3D>GqL((/C ea&e'|PS@3aQ@-hL /@@ ,v@@@@@@@@@@@@@@v, '*v, '^@\ ja+/Lru>]96]d_4W 9o][*A;J&..;a?@ /@@@ @@@@@@@@@@@@@@@@@@@v,,,@@@@@ @@\ O'x.RmTPRK+Pol# U;o_wP`}6.g#?y |@@@@v, '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| 0`.lHNxLXjI^#S 5F-XcldGh_BZDc |@@@@@^ '^^@@@@@@@@@@@@@@@@@'@@@@ '@@@@| JTLKD)#e*CUo$. {c&a46;+AaGW*M |@@@@' '^@@@@@@@@@@@@@ @@@@@v '@@| R5".bytes{n=n* 90+-_1%91};190 |@@^ @@@@@@@@@@@@@ ^^^''' '@| .times{x+=e=(g []+g[].i)*T/R; |^' @@@@@@@@@@@@@vv, @| e==0?s<<<(1..(d==0 ?h*w=h*4:25*w= | ,@@@@@@@@@@@^' | 80)).map{|i|q= i/w*6+3;r=i%w;" \ v@@@@@@@@@@@ / \s'*^,:v@\nXa=# {"%04o"%b};eval$ \ @@@@@@@@@@@@ / s=%q\x21#$s\x21" [r>0?X&&r==(X+168 \ @@@@@@@@^' ,v* / )%R*w/R&&q/6==(90 -Y)*h/180?9:(0..2) \ ^^^^^^' ,^ / .all?{e=d==0?cos(q* T/w/3):(r*3i-120i-q+ \ / 73)/Complex.polar(72 ,2/4.9);q-=2;y,x=e.re -_, _- ct;e.abs<1&&n+=n-s.ma p{|s|z=sqrt(1-y*y);c=d== -_v,, _- 0?r*T/(1-w):b*T/R+acos(x );g=0;s.sum{(g-g=atan2(sin( --__v, __-- o=_1+c),z/tan(_2)+y*cos(o)) /T).round}}.min/9}?n%8:i+9:8]} ```---------``` *""~.gsub(/\x20.*\x20|\n/){})!

Slide 14

Slide 14 text

TRICK 2022: mame.rb • It prints itself with a globe rotated 45 degrees – Eight execution will return the original code a=0132;eval$s=%q!eval(%q~d,h,Y ___---------___ ,X=*$*.map(&:to_i),45;b=(a+d)% R=360;s=[v=[include(Math)]] _--- ---_ ;T=PI*2;n=x=0;f=->{(n/=2)%2 >0?1:f[]*2+(n/=2)%2};g=- _- v@v ,,,,,, -_ >{z=f[];z/2*(3-z%2*6)};" 8'8f'y;I;asr1mY?Sr$6r _- ,vv@@@@@@@^''@v,-_ {+Gi{03G3=ZbpUo3l'}Yw CqxJfHIWd'R /v ,@@@@@@@@@@@v ^^^'''^@@@@\ MUS4&$r3D>GqL((/C ea&e'|PS@3aQ@-hL /@@ ,v@@@@@@@@@@@@@@v, '*v, '^@\ ja+/Lru>]96]d_4W 9o][*A;J&..;a?@ /@@@ @@@@@@@@@@@@@@@@@@@v,,,@@@@@ @@\ O'x.RmTPRK+Pol# U;o_wP`}6.g#?y |@@@@v, '@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@| 0`.lHNxLXjI^#S 5F-XcldGh_BZDc |@@@@@^ '^^@@@@@@@@@@@@@@@@@'@@@@ '@@@@| JTLKD)#e*CUo$. {c&a46;+AaGW*M |@@@@' '^@@@@@@@@@@@@@ @@@@@v '@@| R5".bytes{n=n* 90+-_1%91};190 |@@^ @@@@@@@@@@@@@ ^^^''' '@| .times{x+=e=(g []+g[].i)*T/R; |^' @@@@@@@@@@@@@vv, @| e==0?s<<<(1..(d==0 ?h*w=h*4:25*w= | ,@@@@@@@@@@@^' | 80)).map{|i|q= i/w*6+3;r=i%w;" \ v@@@@@@@@@@@ / \s'*^,:v@\nXa=# {"%04o"%b};eval$ \ @@@@@@@@@@@@ / s=%q\x21#$s\x21" [r>0?X&&r==(X+168 \ @@@@@@@@^' ,v* / )%R*w/R&&q/6==(90 -Y)*h/180?9:(0..2) \ ^^^^^^' ,^ / .all?{e=d==0?cos(q* T/w/3):(r*3i-120i-q+ \ / 73)/Complex.polar(72 ,2/4.9);q-=2;y,x=e.re -_, _- ct;e.abs<1&&n+=n-s.ma p{|s|z=sqrt(1-y*y);c=d== -_v,, _- 0?r*T/(1-w):b*T/R+acos(x );g=0;s.sum{(g-g=atan2(sin( --__v, __-- o=_1+c),z/tan(_2)+y*cos(o)) /T).round}}.min/9}?n%8:i+9:8]} ```---------``` *""~.gsub(/\x20.*\x20|\n/){})! a=0207;eval$s=%q!eval(%q~d,h,Y ___---------___ ,X=*$*.map(&:to_i),45;b=(a+d)% R=360;s=[v=[include(Math)]] _---@^^@@, ^@@@@---_ ;T=PI*2;n=x=0;f=->{(n/=2)%2 >0?1:f[]*2+(n/=2)%2};g=- _-@@@''''' *^ ''^^^v-_ >{z=f[];z/2*(3-z%2*6)};" 8'8f'y;I;asr1mY?Sr$6r _-^''@^ -_ {+Gi{03G3=ZbpUo3l'}Yw CqxJfHIWd'R / ^@ ^@v\ MUS4&$r3D>GqL((/C ea&e'|PS@3aQ@-hL / ,,v@@@@\ ja+/Lru>]96]d_4W 9o][*A;J&..;a?@ / v@@@vv, ,:'''''@\ O'x.RmTPRK+Pol# U;o_wP`}6.g#?y | @@@@@@@@v ,v@@@@@@vv^ | 0`.lHNxLXjI^#S 5F-XcldGh_BZDc | @@@@@@@@@@, v@@@@@@@@@@@, | JTLKD)#e*CUo$. {c&a46;+AaGW*M | @@@@@@@@@@@ v@@@@@@@@@@@@@@@| R5".bytes{n=n* 90+-_1%91};190 | ^@@@@@@@@@@@v, @@@@@@@@@@@@@@@| .times{x+=e=(g []+g[].i)*T/R; | @@@@@@@@@@@@@@ '@@@@@@@@@@@@@@| e==0?s<<<(1..(d==0 ?h*w=h*4:25*w= | ,@@@@@@@@@@@@^ @@@@@@@v| 80)).map{|i|q= i/w*6+3;r=i%w;" \ v@@@@@@@@^^'' @@@@@@^/ \s'*^,:v@\nXa=# {"%04o"%b};eval$ \@@@@@^' @@@@@@'/ s=%q\x21#$s\x21" [r>0?X&&r==(X+168 \^' v@@@@@ / )%R*w/R&&q/6==(90 -Y)*h/180?9:(0..2) \ v@@@@@/ .all?{e=d==0?cos(q* T/w/3):(r*3i-120i-q+ \ @@@@@/ 73)/Complex.polar(72 ,2/4.9);q-=2;y,x=e.re -_ @@@_- ct;e.abs<1&&n+=n-s.ma p{|s|z=sqrt(1-y*y);c=d== -_ _- 0?r*T/(1-w):b*T/R+acos(x );g=0;s.sum{(g-g=atan2(sin( --__ __-- o=_1+c),z/tan(_2)+y*cos(o)) /T).round}}.min/9}?n%8:i+9:8]} ```---------``` *""~.gsub(/\x20.*\x20|\n/){})! 45-degree rotation

Slide 15

Slide 15 text

TRICK 2022: mame.rb • Features – The rotation angle can be specified: ruby mame.rb 30 – The map can be dumped • Techniques – ASCII-art code – Stateful quine – Some algorithm (Compression of polygon map data) – Some math (Spherical trigonometry)

Slide 16

Slide 16 text

Tips: ASCII-art programming in Ruby • %w (string array notation) • with Array#join %w(foo bar) #=> ["foo", "bar"] %w(foo bar).join #=> "foobar"

Slide 17

Slide 17 text

Tips: ASCII-art programming in Ruby (cont'd) • … with "eval" • Now able to format Ruby code as you like eval(%w( pu ts "H el lo ,w or ld ").join) #=> Hello,world eval %w(p u t s " h i ").join #=> hi

Slide 18

Slide 18 text

Stateful Quine • Non-stateful Quine • Stateful Quine eval s=%q(puts " eval s=%q(#{s})") n=1;eval s=%q(puts "n=#{n+1};eval s=%q(#{s})") $ ruby stateful-quine.rb n=2;eval s=%q(puts "n=#{n+1};eval s=%q(#{s})") $ ruby stateful-quine.rb | ruby n=3;eval s=%q(puts "n=#{n+1};eval s=%q(#{s})") $ ruby stateful-quine.rb | ruby | ruby n=4;eval s=%q(puts "n=#{n+1};eval s=%q(#{s})")

Slide 19

Slide 19 text

TRICK 2022: "Best fishbowl" award by tompng eval((s=%~c=(0..35 ).map{s[2*_1+1]}*'';class$Inte ger;def$quXinclude(Math ;spXo(a)=self* a.pow(87X=h=32.chr;g=PI/480;ls=(sp*31X,89)%89; def$abX+'eval((s=%'+(n=? .next)+s*88.chr+[nXs()=[a =self%X+'.split(',sp*25+'?'+88.chr+');(0..36).mapX89,89- a].miX{s[2*_1].split}',sp*31+".join.tr('$',$/)))"]*$/)Xn;end ;reqX.split$/;trap(:INT){puts;exit};q=->t,i{a,y=((t+i*99)Xuire 'matrX%960). ivmod(80);[(a*(7+i)+i*23)%79+(y+a)/(5+i%4)%2,39Xix';1 5.tiX-y/2]};p=->t,u{a=->b,c{(0..5).sum{(u%2-1)*E**(t*(b+c*_1)*gXmes{ |i,*X.i+ i*u+=5+sin(u*u))}};x,z=a[5,3]. 5,3].rect;x+=y.Xv|z= *?!Xi a[19,4];z+=w;r=(4+(x.abs+z.i).ab };t=(0..959).fX..? W,?Xind{|t|(0..29).all?{x,y=q[t,_1];(x 2||h=ls[y][x]X[,* ?]..X[/[^!-}]/]}};h=($**h+h).chr;eval( []} ->(x,yX?};a =(0X,a,b){x=x*36+39.5;y=19.5-y*18;b*=1 |i|((yX..1 34)X-b).ceil..y+b).map{|j|((x-i)/a+(y j)/ .times{X.ma p{zXx,z=p[t,_1];l=u```=0;while``````(l<1)``; u+```=0 ;d=x-y;X.in dex(Xl+=(d.abs+(z-w``)``.i).ab``s*1.``1 ;x``,z=y``,w;o[v``=``x.r d.imag/Xc[i+ 15*Xd.abs*l*sin(2*``l-t``*g*80``-_1) l*(``1-l)/``6,a``=l*( -l)**2*0.X_1] )};X7,a*2]&&o[v,z,``0.0``3,l**`` ``times``{|i``|(8+i).times{|Xw=* MatXj|o[sin(i)/2+````` ```sin( `/2.0`````````)*j/200,j*0.0Xrix [*(X5-1,0.02,0.1]``}} ``. q[t,``_1];m``[y][x]= };i=-X0.. 44).X1;$><<(['%%','[H .map{|j|(0..79).map{|k|x=(Xmap{ |i,X -39.5)/35.8;y=( i+=1;m[j][k]?h:c[i]):ls[j]X*b| v<l { v9 { P l ga%]AK$#BrjXb<

Slide 20

Slide 20 text

tompng.rb • 960-frame fishbowl animation – Each frame is an executable Ruby code (Quine) • Techniques – ASCII-art code – Stateful Quine – 2D graphics for fish and grass – Error correction

Slide 21

Slide 21 text

tompng3.rb eval((s=%~c=(0..35 ).map{s[2*_1+1]}*'';class$Inte ger;def$quXinclude(Math ;spXo(a)=self* a.pow(87X=h=32.chr;g=PI/480;ls=(sp*31X,89)%89; def$abX+'eval((s=%'+(n=? .next)+s*88.chr+[nXs()=[a =self%X+'.split(',sp*25+'?'+88.chr+');(0..36).mapX89,89- a].miX{s[2*_1].split}',sp*31+".join.tr('$',$/)))"]*$/)Xn;end ;reqX.split$/;trap(:INT){puts;exit};q=->t,i{a,y=((t+i*99)Xuire 'matrX%960). ivmod(80);[(a*(7+i)+i*23)%79+(y+a)/(5+i%4)%2,39Xix';1 5.tiX-y/2]};p=->t,u{a=->b,c{(0..5).sum{(u%2-1)*E**(t*(b+c*_1)*gXmes{ |i,*X.i+ i*u+=5+sin(u*u))}};x,z=a[5,3]. 5,3].rect;x+=y.Xv|z= *?!Xi a[19,4];z+=w;r=(4+(x.abs+z.i).ab };t=(0..959).fX..? W,?Xind{|t|(0..29).all?{x,y=q[t,_1];(x 2||h=ls[y][x]X[,* ?]..X[/[^!-}]/]}};h=($**h+h).chr;eval( []} ->(x,yX?};a =(0X,a,b){x=x*36+39.5;y=19.5-y*18;b*=1 |i|((yX..1 34)X-b).ceil..y+b).map{|j|((x-i)/a+(y j)/ .times{X.ma p{zXx,z=p[t,_1];l=u```=0;while``````(l<1)``; u+```=0 ;d=x-y;X.in dex(Xl+=(d.abs+(z-w``)``.i).ab``s*1.``1 ;x``,z=y``,w;o[v``=``x.r d.imag/Xc[i+ 15*Xd.abs*l*sin(2*``l-t``*g*80``-_1) l*(``1-l)/``6,a``=l*( -l)**2*0.X_1] )};X7,a*2]&&o[v,z,``0.0``3,l**`` ``times``{|i``|(8+i).times{|Xw=* MatXj|o[sin(i)/2+````` ```sin( `/2.0`````````)*j/200,j*0.0Xrix [*(X5-1,0.02,0.1]``}} ``. q[t,``_1];m``[y][x]= };i=-X0.. 44).X1;$><<(['%%','[H .map{|j|(0..79).map{|k|x=(Xmap{ |i,X -39.5)/35.8;y=( i+=1;m[j][k]?h:c[i]):ls[j]X*b| v<l { v9 { P l ga%]AK$#BrjXb<

Slide 22

Slide 22 text

tompng3.rb eval((s=%~c=(0..35 ).map{s[2*_1+1]}*'';class$Inte ger;def$quXinclude(Math);spXo(a)=self* a.pow(87X=h=32.chr;g=PI/480;ls=(sp*31X,89)%89; def$abX+'eval((s=%'+(n=?}.next)+s*88.chr+[nXs()=[a =self%X+'.split(',sp*25+'?'+88.chr+');(0..36).mapX89,89- a].miX{s[2*_1].split}',sp*31+".join.tr('$',$/)))"]*$/)Xn;end ;reqX.split$/;trap(:INT){puts;exit};q=->t,i{a,y=((t+i*99)Xuire 'matrX%960).divmod(80);[(a*(7+i)+i*23)%79+(y+a)/(5+i%4)%2,39Xix';1 5.tiX-y/2]};p=->t,u{a=->b,c{(0..5).sum{(u%2-1)*E**(t*(b+c*_1)*gXmes{ |i,*X.i+6i*u+=5+sin(u*u))}};x,z=a[5,3].rect;y,w=a[5,3].rect;x+=y.Xv|z= *?!Xi+a[19,4];z+=w;r=(4+(x.abs+z.i).abs)/1.5;[x/r,z/r]};t=(0..959).fX..? W,?Xind{|t|(0..29).all?{x,y=q[t,_1];(x+y*2i-40-40i).abs>32||h=ls[y][x]X[,* ?]..X[/[^!-}]/]}};h=($**h+h).chr;eval(%!loop{m=(0..39).map{[]};o=->(x,yX?};a =(0X,a,b){x=x*36+39.5;y=19.5-y*18;b*=18;((x-a*=36).ceil..x+a).map{|i|((yX..1 34)X-b).ceil..y+b).map{|j|((x-i)/a+(y-j)/b.i).abs<1&&m[j][i]=1}}};3.times{X.ma p{zXx,z=p[t,_1];l=u```=0;while``````(l<1)``;y,w``=p[t-u+```=0.2,_1];d=x-y;X.in dex(Xl+=(d.abs+(z-w``)``.i).ab``s*1.``15;x``,z=y``,w;o[v``=``x.real+d.imag/Xc[i+ 15*Xd.abs*l*sin(2*``l-t``*g*80``-_1)``/8,z``+l*(``1-l)/``6,a``=l*(1-l)**2*0.X_1] )};X7,a*2]&&o[v,z,``0.0``3,l**``4/`6``]end``};8.``times``{|i``|(8+i).times{|Xw=* MatXj|o[sin(i)/2+`````````sin(``-t*```g*20``+i+j``/2.0`````````)*j/200,j*0.0Xrix [*(X5-1,0.02,0.1]``}};30``.time`````s``{x,y``````=q[t,``_1];m``[y][x]=1};i=-X0.. 44).X1;$><<(['%%','[H','[J%;'<<13]*27.chr+(0..39).map{|j|(0..79).map{|k|x=(Xmap{ |i,Xk-39.5)/35.8;y=(j-19.5)/17.9;(1>r=x*x+y*y)?(i+=1;m[j][k]?h:c[i]):ls[j]X*b| v<lx{+8+H1v9"l[{L.FP)l|Dga%]AK$#BrjXb<

$rL+5g,j]Tf1^B

Slide 23

Slide 23 text

Note • Both of the above two were Quine • But TRICK is not a contest for Quine

Slide 24

Slide 24 text

TRICK 2013: "Best pangram" award by kinaba • This code consists of all printable ASCII characters (32..126) • This code outputs all printable ASCII characters !@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz&[%r{\"}mosx,4>6]|?'while(putc 3_0-~$.+=9/2^5;)<18*7and:`# $ ruby kinaba1.rb !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~

Slide 25

Slide 25 text

kinaba1.rb • Under a pangram – A local variable: You can define one, but you cannot read it – A number: Need to make by calculation – Unneeded symbols: Need to discard well \"}mosx,4>6]|?'while(putc 3_0-~$.+=9/2^5;)<18*7and:`# Use of a special variable $. 9/2^5 = 1 3_0 = 30 18*7 = 126

Slide 26

Slide 26 text

TRICK 2018: "Most reserved" award by kinaba • This is a no-op program that consists only of all reserved words alias BEGIN for unless def class super true or return defined? next break while begin undef do end rescue then retry else undef module nil ensure case if yield __LINE__ self and redo elsif not __FILE__ alias END in end when __ENCODING__ end until false end

Slide 27

Slide 27 text

TRICK 2022: "Most anti-gravity" award by mame 2022;"# .chars} {puts'TRICK+2022' \ { ; #';$><< b ?! };#{s=' ' # 0 ! s[0]? ( b=$<.read ;' } ub( ,''} ';a= ''<<32 b.lines {puts( ?.. *( b.size) .gsub(/./) { b.sub!( /^#$`\K(\S) /x,a)?$1:a } .rstrip)}): ( [ 12,1,12,11]. cycle { | i | t = ( s * 10<< 10)* 10+ %(\e[A)* 10 10. times{t[i* _1 ] = 'TRICK+2022'[ _1 ] };$><

Slide 28

Slide 28 text

mame2.rb 2022;"# .chars} {puts'TRICK+2022' \ { ; #';$><< b ?! };#{s=' ' # 0 ! s[0]? ( b=$<.read ;' } ub( ,''} ';a= ''<<32 b.lines {puts( ?.. *( b.size) .gsub(/./) { b.sub!( /^#$`\K(\S) /x,a)?$1:a } .rstrip)}): ( [ 12,1,12,11]. cycle { | i | t = ( s * 10<< 10)* 10+ %(\e[A)* 10 10. times{t[i* _1 ] = 'TRICK+2022'[ _1 ] };$><<<

Slide 29

Slide 29 text

mame2.rb 2022;"# .chars} {puts'TRICK+2022' \ { ; #';$><< b ?! };#{s=' ' # 0 ! s[0]? ( b=$<.read ;' } ub( ,''} ';a= ''<<32 b.lines {puts( ?.. *( b.size) .gsub(/./) { b.sub!( /^#$`\K(\S) /x,a)?$1:a } .rstrip)}): ( [ 12,1,12,11]. cycle { | i | t = ( s * 10<< 10)* 10+ %(\e[A)* 10 10. times{t[i* _1 ] = 'TRICK+2022'[ _1 ] };$><<< b .gsub(''<<32,'') };#?!=' ' 12,{puts()?..\*: !;s{s]? ( i |ub(/./`\{(}S* }.a[0es [ = s/x/^#$$1Ka[}[ '.l=ne) | 1,,a)?ri:)2) b.siz!( ] 't.rst1]p* i bysib1( ] lT12,1[s.* ' b0cue1{ }%=\(eA)t c0K}t 10. }$ < ) 1 p 1 1 " upward gravity left.rb: "Left gravity" program

Slide 30

Slide 30 text

mame2.rb 2022;"# .chars} {puts'TRICK+2022' \ { ; #';$><< b ?! };#{s=' ' # 0 ! s[0]? ( b=$<.read ;' } ub( ,''} ';a= ''<<32 b.lines {puts( ?.. *( b.size) .gsub(/./) { b.sub!( /^#$`\K(\S) /x,a)?$1:a } .rstrip)}): ( [ 12,1,12,11]. cycle { | i | t = ( s * 10<< 10)* 10+ %(\e[A)* 10 10. times{t[i* _1 ] = 'TRICK+2022'[ _1 ] };$><<< b .gsub(''<<32,'') };#?!=' ' 12,{puts()?..\*: !;s{s]? ( i |ub(/./`\{(}S* }.a[0es [ = s/x/^#$$1Ka[}[ '.l=ne) | 1,,a)?ri:)2) b.siz!( ] 't.rst1]p* i bysib1( ] lT12,1[s.* ' b0cue1{ }%=\(eA)t c0K}t 10. }$ < ) 1 p 1 1 " 2022;"#{puts'TRICK+2022'} .chars}\#{b=$<.read;0;'( #';$><K}t 10.}$<) 1p1 1" Prints "TRICK+2022" up and then left

Slide 31

Slide 31 text

mame2.rb 2022;"# .chars} {puts'TRICK+2022' \ { ; #';$><< b ?! };#{s=' ' # 0 ! s[0]? ( b=$<.read ;' } ub( ,''} ';a= ''<<32 b.lines {puts( ?.. *( b.size) .gsub(/./) { b.sub!( /^#$`\K(\S) /x,a)?$1:a } .rstrip)}): ( [ 12,1,12,11]. cycle { | i | t = ( s * 10<< 10)* 10+ %(\e[A)* 10 10. times{t[i* _1 ] = 'TRICK+2022'[ _1 ] };$><<<<<'=$ts(?..*( #';{s='b32ub(/./){ ?!#0]?(}pu$`\K(\S) };[(,'') 10.=p1} 10]} 10]e _1e _1 sl }"

Slide 32

Slide 32 text

mame2.rb • The TRICK for left gravity • The TRICK for upward gravity "\ #{code1} # {code2}" "\#{code1} #{code2}" left gravity "x x#{code1} xx{code2} " "x{code1} x#{code2} xx " upward gravity

Slide 33

Slide 33 text

Are you getting interested? • Introduced weird Ruby programs and explained implementation tips – For other winning entries of TRICK, check: No k! http://github.com/tric /

Slide 34

Slide 34 text

IMPORTANT NOTICE • We are accepting submissions for TRICK 2025! –Deadline: Feb. 28, 2025 – Announce: Apr. 16--18, 2025 @ RubyKaigi 2025 – We want your weird Ruby programs! http://github.com/tric/trick2025

Slide 35

Slide 35 text

rubyconf-chicago-quine.rb eval$q=%q!z=%w~i:Er(>.YA$zlRYC(g])1yTn.DR:):kL*4$oKjR[vX6ZpI[$qvFXYf>'5ZC=ac;Bz'^A(zfLq&PwshzQm-c:](R&KZPz1y7WR(^e@7/8haoEl9&Ry;yG m^[:if(GV}BVEAHY60c7`>4x]Sh>S*Ibc88f$(-MHJd;>aC)T&/&{0IH(#J{i1=::a`cA.'Q3,/Cf$q4m60F2gD6|JNeXSECT2yNlTMM]hVPd{'ApbVng8;n|GTOnN yEWmYf-:]l`dQ$r+$`NV>A'cEj5bx1j.F|Q?&CFYW+e;NSR'/tc(?tSS}55nf6kn:b:Vo5%O6KCXy2CQYS<{YwsG$U{IcJT;`I$a&Zx|9iC6..G^20ra;ut=LFp^)P lOv4MZ/ #1]zM VnP_u rX4 4$hfs* ;G%yG >tO3K0.Bn nz'u &[lw us+mS r{Ol f&Y`0-' ^8u$J?F ^?Xe 6E`( Tf=Z1 Plm WS3K V]El CjGGe 3%cHWu0 y,IHw1^S Vj_nr i}P 2G L'zk }W1SC'@/rd)vRlv fcS%lUw +B/j= J,a AlqhI ib@ }Nv3R Mb5 '/8<5 '#jQDO TIM_[#MBox y8iTJ ;-Y W # 1J=N Sx,A|]da2>Fd^)7 +IF$}fu 0Cit cjWB gk-4u '`# MGj< Q1H[ B:(5R GJsnB X_U53OF<-sU #RoDL SiE x - ArRA M2ImaFuFRL xk0&'lW FJ,,W dQ1Pq ?tw YRY0@U ; F++2Df ORl@,tcPBdv BN64m D%b m P 0%J4 -VAF3jGL u%za#kj cDtp }STK^U Mq>dx o1 E^Wc 9|,$a/rm,R2}|#z /Hode{j SA<|Q f;p' L;+# (xahkag5 `3K>YV-oURoyu 'Dkt 5'l0 fW`cY =_Ug w_bGU|>+9_9)V0. >BJ_*u&):C+?q7fB*R*,HkX?S,wGGmg/k,Jk4&_*h(XT=hcmFv$s5qk9zxtjAX@/;K^MVgFn$vtP*bPSeo'2?uN%kL_XD%Ga{BDjVLWW)|cMw:9^Vgr<6hE<5ffX-_ 7O^sJq#d`0xgT1e%:cuAoz0))T']sKhK&>'3^)HV3:c-F*yBQg{PKMeugAO-Vq?l|M?:0'$4n?+TR$DU*v-jk8$Q^-n2u;KDPl94AA6]d@+UTV&NYW^I$+g]tW:]vQP?Na5RU5owPqOu8$?98iOcH,j=*oAJH-jV1LXBuH|Fc=*]U%sF&FmX/BX K+X(>A2h~*"";eval(%w~c=0;z.bytes{c=c *90+( _1-1 )%91-1};z =+"";(z<0);55.upto (249){z=z[2..].gsub(""<<_1){z[0,2]}};z=z.byt es. each_ slice(3).to _a;Z=32 .chr;E="\e[";W=[128]*S=846008;j=100;n=z.m ap{|v,t,l|l*=804;t>0?(n=t=(n)?n+t-1:t-1;t=55 *2* *((t- 4)/12.0);l. times{ |i|f=i*Math::PI*t/4020;W[j+i]+=v>0?[40-i/4 00.0,0].max*Math.sin(f/2):[10-i*8.0/l,0].ma x*M ath.s in(f+Math. sin(f ))}):(n=p;j+=l)};File.write("chicago.wav",[ "RIFF",S+36,"WAVEfmt"+Z,16,1,1,8040,8040, 1,8," data" ,S].pack ("A4VA 8VvvVVvvA4V")+W.pack("C*"));D=->i,n{E+"#{n}m #{(0..8).map{|y|a=3*2741[j=i%12];E+"#{y +31};#{ 1+x=y <5?i*2 1/12+74 2[j ]:i/12*21+j*3/5*3}H"+(y<5&&a<1?Z*2:"[#] "[x%3,y<5?3451[j]+1:a])}*""+E}m"};q=3 3.chr;$>< <"#\e [30m \n#{q=%(e val$q=%q#{q+$q+q};%:)}:\n__END__\n\e[ ?25l\e[H\e[J\e[1;30r";at_exit{puts(E +"r\e[43;1H \e[?2 5hc hicago.wav_is_sav ed".tr(?_,Z))};72.times{$><<0&&(a<<[v,n=(n)?n+t-1:t-1,l,?V];d[-1]<<[n,v*2+42]));l.times{b=[];s=[Z]*126;a.map{|v,t,l,h|l>0?(s[t/12*21+t%12*1 8/11+10+1930[t%12]]=E+"#{v*2+32}m#{h+E}m";b<<[v,t,l-1,?|]):d[-1].unshift([t,0])};a=b;$><0?s*"":q.pop)+d.shift.m ap{|t,v|D[t+5,v]}*""}";d<<[];c+=1;1while(Time.now-o

Slide 36

Slide 36 text

No content