SlideShare a Scribd company logo
1 of 38
TRICK
@jimmynguyc
What is TRICK
• Transcendental Ruby Imbroglio Contest for
RubyKaigi
• A Ruby programming contest started and held in
RubyKaigi 2013
• TRICK2015 is happening this year 😇
What is TRICK
• Transcendental /ˌtranˌsenˈden(t)l/
- of or relating to a spiritual or nonphysical realm
- unworldly
• Imbroglio /imˈbrōlyō/
- an extremely confused, complicated, or embarrassing situation
Goal of TRICK
• Write the most Transcendental, Imbroglio Ruby Program
• To illustrate some of the subtleties (and design issues) of Ruby.
• To show the robustness and portability of Ruby interpreters.
• To stabilize the spec of Ruby by the presence of valuable but
unmaintainable code.
Related Contests
• IOCCC: International Obfuscated C Code Contest
• UCC: Underhanded C Contest
• OPC: Obfuscated Perl Contest
• IORCC: International Obfuscated Ruby Code Contest
IOCCC Winner 2014
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#define A calloc(1, sizeof(m))
#define D m.
#define L ->
#define P malloc(
#define R &&
#define S ++
#define U for(
#define V if(
#define W L i
#define X L a
#define Y L b
#define Z L c
typedef struct T*_; struct T{ int t,i; char*a; _*b,c,d,e,f; } m,x,y; struct stat z; int u; void * H;
int K(int c){ return strchr(" nt",c); } void B(_ s,_ p) { s Y=realloc(s Y,S s W*sizeof(_)); s Y [s
W-1]=p; } _ C(char*d,int l){ _ s=A; s X=d?d:P 1); s W=l<0?d?strlen(d):0:l; return s; } _ E(_ s){ _ r
=A; int i=0; U; i<s W; ){ U; i<s W R K(s X[i]); )i S; int j=i; U; j<s W R !K(s X[j]); )j S; V j-i)B(
r,C(s X+i,j-i)); i=S j; } return r; } int F(_ a,_ b){ return a W==b W R !memcmp(a X,b X,a W); } void
I( _ s,char c ) { char*d=P 1); *d=c ; B(s,C(d,1) ); } void
J ( char*d,int l ,int o,_ v){ _ n= C(d,l); _ w; U l= 0; l
<D d W; ) { w= D d Y[l S ]; V F( w Z,n)){ V o>w W) return; goto O; } }
B( D d,w= A ); w Z=n; O:w W =o ; w L d=v; } int M( _ b,int p,char*t,int
g ){ _ f= A; f L e= A; f X=t; int h=g ,i=0,j=0,n=b
W ; char c=0, d,*o =b X ; U; p<n; ){ t=j?"":f X ;
int k=p; _ r=H ; U; p <n; ){ int l = 0; U; p<n R o[p]==92 ; ){ l S; p S; } c=o
[p S ]; V c^10||! l% 2 ||!g){ d=c== 35 R !i R!g|| c== 10 R g^2; V d||strchr(t,c
)) { r=C(o+k,p-k- d*l/ 2-1); V d R l%2) { r X[r W-1] =c^35 ?32:
c; c =0; } break; } } c=0; } V!j)B (f L e,r?r:C(o+k, n-k) ); r
=A; switch(c){ case 35:j S; case 0:break; case 10:goto O; case 36:switch(d=o[p S]){ case 36:I(f L e,
d); break; default:I(r Z=A,d); goto o; case 40:case 123:r L f=f; r L e=A; r X=d^40?"}$":")$"; f=r; }
break; default:V f L f){ r Z=f L e; f=f L f; o:r L t S; B(f L e,r); } else goto O; } i=f L f R g==1;
g=i?0:h; } O: x.c=f L e; x.t=c; return p; } _ N(_ s){ _ o=C(H,0); U int i=0; i<s W; ){ _ p=s Y[i S];
V p L t){ _ n=N(p Z); p=C(H,0); U int j=0; j<D d W; ){ _ w=D d Y[j S]; V F(w Z,n)){ M(w L d,0,"$",2)
; p=N(x.c); break; } } } o X=realloc(o X,o W+=p W); memcpy(o X+o W-p W,p X,p W); } return o; } _ O(_
t){ U int i=0; i<D e W; ){ _ s=D e Y[i S]; V F(s Z,t))return s; }_ s=A; s Z=t; s L d=A; s L t--; B(D
e,s); return s; } void Q(_ s){ _ d=s Z; V!stat(memcpy(calloc(1,d W+1),d X,d W),&z))s L t=z.st_mtime;
V!s W S){ u=!s L d W R s L t<0; int i=0,j,k=s L t<0; _ c=H,t; U; !u R i<s L d W; ){ _ a=s L d Y[i S]
; U j=0; !u R j<a L d W; ){ Q(t=O(a L d Y[j S])); k|=t L t<0||t L t>s L t; } V a Z W){ c=a Z; V a L
d W)J("<", 1, 0, *a L d Y); } } U j=0; !u R c R k R j<c W; ){ J("@",1,0,d); s=N(c Y[j S]); U; s W R
strchr("@+-",*s X); )s X S; u=system(s X); } } } void G(_ b){ U; b W R K(*b X); ){ b X S; b W--; } }
int main(int i,char**a,char**e){ D d=A; D e=A; D c=A; char p[]="NBLF1Nblfgjmf1",*q=p; U; (*q++)--;
); J(p,4,0,C(*a S,-1)); U i=0; i<3; i+=2){ U; *a; ){ q=*a; U; *q R*q^61; )q S; V*q)J(*a,q-*a,i+1,C(q
+1,-1)); else V!i)B(D c,C(*a,-1)); a S; } a=e; } stat(p+5,&z); i=z.st_size; _ b=C(H,0),c,d; b W=read
(open(p+5,0),b X=P i),i); U; u<i; ){ V b X[u]^9){ U; u<i R K(b X[u]); )u S; u=M(b,u,"=:$",0); y = x;
switch(x.t){ case 58:u=M(b,u,"$",0); D f=c=A; c L d=E(N(x.c)); c Z=A; d=E(N(y.c)); U; d W--; )B(O(*d
Y S) L d,c); break; case 61:u=M(b,u,"",0); G(c=N(x.c)); G(d=N(y.c)); U; d W--R K(d X[d W]); ); J(d X
,S d W,2,c); } } else { u=M(b,S u,"$",1); I(x.c,0); B(D f Z,x.c); } } V!D c W R D e W)B(D c,D e Y[0]
Z); U u=0; !u R D c W--; )Q(O(*D c Y S)); return u; }
TRICK 2013
• Judges
‣ Yusuke Endoh (@mametter. Ruby committer. IOCCC winner)
‣ Koichiro Eto (@eto. Media Artist. Chairman at NicoNicoGakkai Beta)
‣ Shinichiro Hamaji (@shinh. The admin of anarchy golf. IOCCC winner)
‣ Yutaka Hara (@yhara. The author of Japanese esolang book)
‣ Yukihiro Matsumoto (a.k.a. matz. @yukihiro_matz. The creator of Ruby)
‣ Sun Park (a.k.a. leonid. The 1st super Ruby golfer.)
‣ Hirofumi Watanabe (@eban. Ruby committer. The 2nd super Ruby golfer)
TRICK 2013
• Judging process
‣ Each judge scores each entry on 10 point scale
‣ Judge has no rights to score own entry
‣ Judge keeps each entry anonymous during judgement
‣ 10 winning entries
Top 6 Entries
• No. 6 - “Best way to return true”
• No. 5 - “Most Competitive”
• No. 4 - “Worst abuse of constants”
• Bronze - “Most Classical”
• Silver - “Most Readable”
• Gold - “Best Pangram”
“Best way to Return true”
$ruby.is_a?(Object){|oriented| language}
by Nakamura Usaku
Key TRICKs / Exploits
• nil (like almost everything in Ruby) is an Object
• methods don’t check if it accept blocks
• codes that are not evaluated until needed
$ruby.is_a?(Object){|oriented| language}
“Most Competitive”
eval$s =(%q(;eval((%w(Z=" s"*2;V="1sj6w3u1i kfyikb6y01xsjdceda
j4".to _i(36);R=0..9;a,b= [[*$s.lines],[*$<] ].map{|s|n=0;1.ste
p(w=s. map{|l|l.chomp.siz e}.max,2+3*m=48/(w -70)){|x|n=n*10+R.
find{|n|R.al l?{|i| V[n*15 +i]<1= =Z<(s[ i/3*3+
1][i%3*m+x]| |Z)}}} ;n};d= 10**(( b-a)/4 e2);[[
STDOUT,a+d=d *32/(d +1)],[ $stdou t,b-d] ].map{
|o,n|; s="eval$s=(%q("+$s [/(.*? ~){3}/ m];15. times{
|y|l=" %d"%(n+0.5);l=(l.b ytes.m ap{|c| (0..2) .map{|
x|"xs "[V[c*15-720+y/3*3 +x]]*( 24/l.s ize)}* "";}*Z
).rstr ip.gsu b(?x){ s<<V.t o_s(20 );s.sl
ice!(/ S/)}; o.puts (y<14? l:l[0. .-4]+"
~))")} ;o.put s})*"" ));;%~ 7h7hhf 1j626e
0dh6392fa6b6b45iid c59c7h7hhf1j626e0d h6392fa6b6b45iidc5 9c7h7hhf1j626e0dh6
392fa6b6b45iidc59c 7h7hhf1j626e0dh639 2fa6b6b45iidc59c7h 7hhf1j626e0dh6392f
a6b6b45iidc59c7h7h hf1j626e0dh6392fa6 b6b45iidc59c7h7hhf 1j626e0dh6392fa~))
by Yusuke Endoh
Demo
Key TRICKs / Exploits
• Quine
• formatting code
• cheat OCR
• calculating Elo Rating
• abuse of -i
eval$s =(%q(;eval((%w(Z=" s"*2;V="1sj6w3u1i kfyikb6y01xsjdceda
j4".to _i(36);R=0..9;a,b= [[*$s.lines],[*$<] ].map{|s|n=0;1.ste
p(w=s. map{|l|l.chomp.siz e}.max,2+3*m=48/(w -70)){|x|n=n*10+R.
find{|n|R.al l?{|i| V[n*15 +i]<1= =Z<(s[ i/3*3+
1][i%3*m+x]| |Z)}}} ;n};d= 10**(( b-a)/4 e2);[[
STDOUT,a+d=d *32/(d +1)],[ $stdou t,b-d] ].map{
|o,n|; s="eval$s=(%q("+$s [/(.*? ~){3}/ m];15. times{
|y|l=" %d"%(n+0.5);l=(l.b ytes.m ap{|c| (0..2) .map{|
x|"xs "[V[c*15-720+y/3*3 +x]]*( 24/l.s ize)}* "";}*Z
).rstr ip.gsu b(?x){ s<<V.t o_s(20 );s.sl
ice!(/ S/)}; o.puts (y<14? l:l[0. .-4]+"
~))")} ;o.put s})*"" ));;%~ 7h7hhf 1j626e
0dh6392fa6b6b45iid c59c7h7hhf1j626e0d h6392fa6b6b45iidc5 9c7h7hhf1j626e0dh6
392fa6b6b45iidc59c 7h7hhf1j626e0dh639 2fa6b6b45iidc59c7h 7hhf1j626e0dh6392f
a6b6b45iidc59c7h7h hf1j626e0dh6392fa6 b6b45iidc59c7h7hhf 1j626e0dh6392fa~))
%~
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa~
)
)
eval$s=(%q(;eval
(
(
%w(
Z="s"*2;V="1sj6w3u1ikfyikb6y01xsjdcedaj4".to_i(36);
R=0..9;
a,b=[[*$s.lines],[*$<]].map{|s|
n=0;
1.step(w=s.map{|l|l.chomp.size}.max,2+3*m=48/(w-70)){|x|
n=n*10+R.find{|n|
R.all?{|i|
V[n*15+i]<1==Z<(s[i/3*3+1][i%3*m+x]||Z)
}
}
};
n
};
d=10**((b-a)/4e2);
[
[STDOUT,a+d=d*32/(d+1)],
[$stdout,b-d]
].map{|o,n|
;s="eval$s=(%q("+$s[/(.*?~){3}/m];
15.times{|y|
l="%d"%(n+0.5);
l=(l.bytes.map{|c|
(0..2).map{|x|
"xs"[V[c*15-720+y/3*3+x]]*(24/l.size)}*"";
}*Z).rstrip.gsub(?x){s<<V.to_s(20);
s.slice!(/S/)
};
o.puts(y<14?l:l[0..-4]+"~))")
};
o.puts})*""
)
);;
%~
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
7h7hhf1j626e0dh6392fa6b6b45iidc59c
Dissection
Calculate Elo Rating
Output code to OCR
Fillers
“Worst Abuse of Constants”
def _(&b)$><<->(x){x ? (String===x ?x.upcase:
(Class===x ? x : x.class).name[$a?0:($a=5)]):
" "}[ begin b[];rescue Exception;$!;end ] end
_ { return }
_ { method(:p).unbind }
_ { eval "{ " }
_ { Thread.current.join }
_ { nil }
_ { select }
_ { ruby }
_ { self.class }
_ { Thread.current.group }
_ { nil.to_h }
_ { "xFF".encode("big5") }
_ { raise }
_ { [0][1] }
_ { Regexp.compile "*" }
_ { RUBY_COPYRIGHT[32] }
_ { binding }
_ { :s.class.name[1] }
_ { warn }
_ { [a: :b][0] }
_ { methods }
_ { IO.class }
_ { {}.fetch(0) }
_ { open " " }
_ { 1000000.chr }
by Yutaka Hara
Dishonarable
Mention
Demo
Key TRICKs / Exploits
• Ruby Constants
• $!
def _(&b)$><<->(x){x ? (String===x ?x.upcase:
(Class===x ? x : x.class).name[$a?0:($a=5)]):
" "}[ begin b[];rescue Exception;$!;end ] end
_ { return }
_ { method(:p).unbind }
_ { eval "{ " }
_ { Thread.current.join }
_ { nil }
_ { select }
_ { ruby }
_ { self.class }
_ { Thread.current.group }
_ { nil.to_h }
_ { "xFF".encode("big5") }
_ { raise }
_ { [0][1] }
_ { Regexp.compile "*" }
_ { RUBY_COPYRIGHT[32] }
_ { binding }
_ { :s.class.name[1] }
_ { warn }
_ { [a: :b][0] }
_ { methods }
_ { IO.class }
_ { {}.fetch(0) }
_ { open " " }
_ { 1000000.chr }
Dissection
def _(&b)
$><<
->(x){
x ? (String === x ? x.upcase : (Class===x ?
x : x.class).name[$a?0:($a=5)]) : " "
}[
begin
b[]
rescue Exception
$!
end
]
end
_ { return }
_ { method(:p).unbind }
_ { eval "{ " }
_ { Thread.current.join }
_ { nil }
_ { select }
_ { ruby }
_ { self.class }
_ { Thread.current.group }
_ { nil.to_h }
_ { "xFF".encode("big5") }
_ { raise }
_ { [0][1] }
...
• $><< to replace “puts”
• ===
• [] to execute block
• $! to return Exception
“Most Classic”
pack"C*"); puts(l)}}};M=
Math);S=%:
Jesu, Joy of Man's Desiring
Johann Sebastian Bach
#
| #
| #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | #
# # # #
| | | #
| #| #
# # | #
| | | #
| | # #
# # # #
| | # |
| | # #
# # # #
| | | #
| | #
# # # #
| | # |
| # # |
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | #
# # # #
| | | #
| #| #
# # | #
| | | #
| | # #
# # # #
| | # |
| | # #
# # # #
| | | #
| | #
# # # #
| | # |
| # # |
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | # #
# # # #
| | | #
| | | #
| # | #
# # # #
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | :
by Yusuke Endoh
BRO
NZE
Demo
Key TRICKs / Exploits
• Quine + music box
• Frequency modulation synthesis
• Uses sound server e.g. PulseAudio
Dissection
Do I have to explain everything?
Can’t you just be amazed?
“Most Readable”
begin with an easy program.
you should be able to write
a program unless for you,
program in ruby language is
too difficult. At the end
of your journey towards the
ultimate program; you must
be a part of a programming
language. You will end if
you != program
by Shinichiro Hamaji
SILV
ER
Demo
Key TRICKs / Exploits
• begin .. end if false
• for statement for defining variables
begin with an easy program.
you should be able to write
a program unless for you,
program in ruby language is
too difficult. At the end
of your journey towards the
ultimate program; you must
be a part of a programming
language. You will end if
you != program
Dissection
begin
with(an(easy(program.you(should(be(able(to(write))))))))
unless (for you, program in ruby(language(is)) do
too(difficult.At(the))
end)
a(program())
end
of(your(journey(towards(the))))
ultimate(program)
you(must)
be(a(part(of(a(programming)))))
language.You(will)
end if (you != program)
whitequark/parser mbj/unparserAST
begin
with an easy program.you
should be able to write
a program unless for you,
program in ruby language is
too difficult. At the end
of your journey towards the
ultimate program;
you must
be a part of a programming
language. You will
end if you != program
“Best Pangram”
!@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz&[%r{"}mosx,4>6]|?'while(putc
3_0-~$.+=9/2^5;)<18*7and:`#
by Kinaba
GOL
D
Demo
What’s a Pangram
• a sentence using every letter of the alphabet at
least once
Key TRICKs / Exploits
• Contains & Prints ASCII Character from 0x20 to
0x7e exactly once
• 0x2016 = 3210 … 0x7e16 = 12610
• !"#$%&'()*+,-
./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRS
TUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
Key TRICKs / Exploits
• 32.upto(126){|x| putc x}
• $.
• 3_0 = 30
• Escape quotes as ” and ?’ and :`
!@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz&[%r{"}mosx,4>6]|?'while(putc
3_0-~$.+=9/2^5;)<18*7and:`#
Dissection
3_0-~$.+=9/2^5;)<18*7
while ((putc(30 - (~($. += ((9 / 2) ^ 5)))) < (18 * 7)) && :`)
((!@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz) & [/"/mosx, (4 > 6)]) | "'"
end
Most Interesting Part
$. => 1 # ruby golfer’s best friend
Google Search Term:
“trick 2013 rubykaigi”
https://github.com/tric/trick2013
Upcoming TRICK
https://github.com/tric/trick2015

More Related Content

What's hot

The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)jeffz
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programmingjeffz
 
Coscup2021-rust-toturial
Coscup2021-rust-toturialCoscup2021-rust-toturial
Coscup2021-rust-toturialWayne Tsai
 
Practical scalaz
Practical scalazPractical scalaz
Practical scalazoxbow_lakes
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageWayne Tsai
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)jeffz
 
Deriving Scalaz
Deriving ScalazDeriving Scalaz
Deriving Scalaznkpart
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation streamRuslan Shevchenko
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscexjeffz
 
Jscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScriptJscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScriptjeffz
 
Why learn new programming languages
Why learn new programming languagesWhy learn new programming languages
Why learn new programming languagesJonas Follesø
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicalsManoj Chauhan
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class PatternsJohn De Goes
 
Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"LogeekNightUkraine
 
Collection v3
Collection v3Collection v3
Collection v3Sunil OS
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmKapil Pandit
 

What's hot (20)

Scalaz
ScalazScalaz
Scalaz
 
The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)The Evolution of Async-Programming (SD 2.0, JavaScript)
The Evolution of Async-Programming (SD 2.0, JavaScript)
 
Javascript Uncommon Programming
Javascript Uncommon ProgrammingJavascript Uncommon Programming
Javascript Uncommon Programming
 
Coscup2021-rust-toturial
Coscup2021-rust-toturialCoscup2021-rust-toturial
Coscup2021-rust-toturial
 
Practical scalaz
Practical scalazPractical scalaz
Practical scalaz
 
Coscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usageCoscup2021 - useful abstractions at rust and it's practical usage
Coscup2021 - useful abstractions at rust and it's practical usage
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)
 
Deriving Scalaz
Deriving ScalazDeriving Scalaz
Deriving Scalaz
 
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
JDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation streamJDays Lviv 2014:  Java8 vs Scala:  Difference points & innovation stream
JDays Lviv 2014: Java8 vs Scala: Difference points & innovation stream
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
 
深入浅出Jscex
深入浅出Jscex深入浅出Jscex
深入浅出Jscex
 
Es.next
Es.nextEs.next
Es.next
 
Jscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScriptJscex: Write Sexy JavaScript
Jscex: Write Sexy JavaScript
 
Why learn new programming languages
Why learn new programming languagesWhy learn new programming languages
Why learn new programming languages
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class Patterns
 
Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"Mikhail Khristophorov "Introduction to Regular Expressions"
Mikhail Khristophorov "Introduction to Regular Expressions"
 
Advance java
Advance javaAdvance java
Advance java
 
Collection v3
Collection v3Collection v3
Collection v3
 
Wap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithmWap in c to draw a line using DDA algorithm
Wap in c to draw a line using DDA algorithm
 

Similar to TRICK

Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tourSimon Proctor
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programmingLukasz Dynowski
 
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Paulo Morgado
 
Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworksKerry Buckley
 
Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»SpbDotNet Community
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick touraztack
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6FITC
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Ismar Silveira
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Er Ritu Aggarwal
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...Andrey Karpov
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語ikdysfm
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regexbrian d foy
 

Similar to TRICK (20)

Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
 
Python 101 language features and functional programming
Python 101 language features and functional programmingPython 101 language features and functional programming
Python 101 language features and functional programming
 
Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7Tuga IT 2017 - What's new in C# 7
Tuga IT 2017 - What's new in C# 7
 
Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworks
 
Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»Дмитрий Верескун «Синтаксический сахар C#»
Дмитрий Верескун «Синтаксический сахар C#»
 
Ruby Language - A quick tour
Ruby Language - A quick tourRuby Language - A quick tour
Ruby Language - A quick tour
 
Operators
OperatorsOperators
Operators
 
Vcs16
Vcs16Vcs16
Vcs16
 
Java operators
Java operatorsJava operators
Java operators
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
 
Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4Paradigmas de Linguagens de Programacao - Aula #4
Paradigmas de Linguagens de Programacao - Aula #4
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
 
C program
C programC program
C program
 
PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...PVS-Studio team experience: checking various open source projects, or mistake...
PVS-Studio team experience: checking various open source projects, or mistake...
 
Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語Haskellで学ぶ関数型言語
Haskellで学ぶ関数型言語
 
Blocks+gcd入門
Blocks+gcd入門Blocks+gcd入門
Blocks+gcd入門
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 

TRICK

  • 2. What is TRICK • Transcendental Ruby Imbroglio Contest for RubyKaigi • A Ruby programming contest started and held in RubyKaigi 2013 • TRICK2015 is happening this year 😇
  • 3. What is TRICK • Transcendental /ˌtranˌsenˈden(t)l/ - of or relating to a spiritual or nonphysical realm - unworldly • Imbroglio /imˈbrōlyō/ - an extremely confused, complicated, or embarrassing situation
  • 4. Goal of TRICK • Write the most Transcendental, Imbroglio Ruby Program • To illustrate some of the subtleties (and design issues) of Ruby. • To show the robustness and portability of Ruby interpreters. • To stabilize the spec of Ruby by the presence of valuable but unmaintainable code.
  • 5. Related Contests • IOCCC: International Obfuscated C Code Contest • UCC: Underhanded C Contest • OPC: Obfuscated Perl Contest • IORCC: International Obfuscated Ruby Code Contest
  • 6. IOCCC Winner 2014 #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> #define A calloc(1, sizeof(m)) #define D m. #define L -> #define P malloc( #define R && #define S ++ #define U for( #define V if( #define W L i #define X L a #define Y L b #define Z L c typedef struct T*_; struct T{ int t,i; char*a; _*b,c,d,e,f; } m,x,y; struct stat z; int u; void * H; int K(int c){ return strchr(" nt",c); } void B(_ s,_ p) { s Y=realloc(s Y,S s W*sizeof(_)); s Y [s W-1]=p; } _ C(char*d,int l){ _ s=A; s X=d?d:P 1); s W=l<0?d?strlen(d):0:l; return s; } _ E(_ s){ _ r
  • 7. =A; int i=0; U; i<s W; ){ U; i<s W R K(s X[i]); )i S; int j=i; U; j<s W R !K(s X[j]); )j S; V j-i)B( r,C(s X+i,j-i)); i=S j; } return r; } int F(_ a,_ b){ return a W==b W R !memcmp(a X,b X,a W); } void I( _ s,char c ) { char*d=P 1); *d=c ; B(s,C(d,1) ); } void J ( char*d,int l ,int o,_ v){ _ n= C(d,l); _ w; U l= 0; l <D d W; ) { w= D d Y[l S ]; V F( w Z,n)){ V o>w W) return; goto O; } } B( D d,w= A ); w Z=n; O:w W =o ; w L d=v; } int M( _ b,int p,char*t,int g ){ _ f= A; f L e= A; f X=t; int h=g ,i=0,j=0,n=b W ; char c=0, d,*o =b X ; U; p<n; ){ t=j?"":f X ; int k=p; _ r=H ; U; p <n; ){ int l = 0; U; p<n R o[p]==92 ; ){ l S; p S; } c=o [p S ]; V c^10||! l% 2 ||!g){ d=c== 35 R !i R!g|| c== 10 R g^2; V d||strchr(t,c )) { r=C(o+k,p-k- d*l/ 2-1); V d R l%2) { r X[r W-1] =c^35 ?32: c; c =0; } break; } } c=0; } V!j)B (f L e,r?r:C(o+k, n-k) ); r =A; switch(c){ case 35:j S; case 0:break; case 10:goto O; case 36:switch(d=o[p S]){ case 36:I(f L e, d); break; default:I(r Z=A,d); goto o; case 40:case 123:r L f=f; r L e=A; r X=d^40?"}$":")$"; f=r; } break; default:V f L f){ r Z=f L e; f=f L f; o:r L t S; B(f L e,r); } else goto O; } i=f L f R g==1; g=i?0:h; } O: x.c=f L e; x.t=c; return p; } _ N(_ s){ _ o=C(H,0); U int i=0; i<s W; ){ _ p=s Y[i S]; V p L t){ _ n=N(p Z); p=C(H,0); U int j=0; j<D d W; ){ _ w=D d Y[j S]; V F(w Z,n)){ M(w L d,0,"$",2) ; p=N(x.c); break; } } } o X=realloc(o X,o W+=p W); memcpy(o X+o W-p W,p X,p W); } return o; } _ O(_ t){ U int i=0; i<D e W; ){ _ s=D e Y[i S]; V F(s Z,t))return s; }_ s=A; s Z=t; s L d=A; s L t--; B(D e,s); return s; } void Q(_ s){ _ d=s Z; V!stat(memcpy(calloc(1,d W+1),d X,d W),&z))s L t=z.st_mtime; V!s W S){ u=!s L d W R s L t<0; int i=0,j,k=s L t<0; _ c=H,t; U; !u R i<s L d W; ){ _ a=s L d Y[i S] ; U j=0; !u R j<a L d W; ){ Q(t=O(a L d Y[j S])); k|=t L t<0||t L t>s L t; } V a Z W){ c=a Z; V a L d W)J("<", 1, 0, *a L d Y); } } U j=0; !u R c R k R j<c W; ){ J("@",1,0,d); s=N(c Y[j S]); U; s W R strchr("@+-",*s X); )s X S; u=system(s X); } } } void G(_ b){ U; b W R K(*b X); ){ b X S; b W--; } } int main(int i,char**a,char**e){ D d=A; D e=A; D c=A; char p[]="NBLF1Nblfgjmf1",*q=p; U; (*q++)--; ); J(p,4,0,C(*a S,-1)); U i=0; i<3; i+=2){ U; *a; ){ q=*a; U; *q R*q^61; )q S; V*q)J(*a,q-*a,i+1,C(q +1,-1)); else V!i)B(D c,C(*a,-1)); a S; } a=e; } stat(p+5,&z); i=z.st_size; _ b=C(H,0),c,d; b W=read (open(p+5,0),b X=P i),i); U; u<i; ){ V b X[u]^9){ U; u<i R K(b X[u]); )u S; u=M(b,u,"=:$",0); y = x; switch(x.t){ case 58:u=M(b,u,"$",0); D f=c=A; c L d=E(N(x.c)); c Z=A; d=E(N(y.c)); U; d W--; )B(O(*d Y S) L d,c); break; case 61:u=M(b,u,"",0); G(c=N(x.c)); G(d=N(y.c)); U; d W--R K(d X[d W]); ); J(d X ,S d W,2,c); } } else { u=M(b,S u,"$",1); I(x.c,0); B(D f Z,x.c); } } V!D c W R D e W)B(D c,D e Y[0] Z); U u=0; !u R D c W--; )Q(O(*D c Y S)); return u; }
  • 8. TRICK 2013 • Judges ‣ Yusuke Endoh (@mametter. Ruby committer. IOCCC winner) ‣ Koichiro Eto (@eto. Media Artist. Chairman at NicoNicoGakkai Beta) ‣ Shinichiro Hamaji (@shinh. The admin of anarchy golf. IOCCC winner) ‣ Yutaka Hara (@yhara. The author of Japanese esolang book) ‣ Yukihiro Matsumoto (a.k.a. matz. @yukihiro_matz. The creator of Ruby) ‣ Sun Park (a.k.a. leonid. The 1st super Ruby golfer.) ‣ Hirofumi Watanabe (@eban. Ruby committer. The 2nd super Ruby golfer)
  • 9. TRICK 2013 • Judging process ‣ Each judge scores each entry on 10 point scale ‣ Judge has no rights to score own entry ‣ Judge keeps each entry anonymous during judgement ‣ 10 winning entries
  • 10. Top 6 Entries • No. 6 - “Best way to return true” • No. 5 - “Most Competitive” • No. 4 - “Worst abuse of constants” • Bronze - “Most Classical” • Silver - “Most Readable” • Gold - “Best Pangram”
  • 11. “Best way to Return true” $ruby.is_a?(Object){|oriented| language} by Nakamura Usaku
  • 12. Key TRICKs / Exploits • nil (like almost everything in Ruby) is an Object • methods don’t check if it accept blocks • codes that are not evaluated until needed $ruby.is_a?(Object){|oriented| language}
  • 13. “Most Competitive” eval$s =(%q(;eval((%w(Z=" s"*2;V="1sj6w3u1i kfyikb6y01xsjdceda j4".to _i(36);R=0..9;a,b= [[*$s.lines],[*$<] ].map{|s|n=0;1.ste p(w=s. map{|l|l.chomp.siz e}.max,2+3*m=48/(w -70)){|x|n=n*10+R. find{|n|R.al l?{|i| V[n*15 +i]<1= =Z<(s[ i/3*3+ 1][i%3*m+x]| |Z)}}} ;n};d= 10**(( b-a)/4 e2);[[ STDOUT,a+d=d *32/(d +1)],[ $stdou t,b-d] ].map{ |o,n|; s="eval$s=(%q("+$s [/(.*? ~){3}/ m];15. times{ |y|l=" %d"%(n+0.5);l=(l.b ytes.m ap{|c| (0..2) .map{| x|"xs "[V[c*15-720+y/3*3 +x]]*( 24/l.s ize)}* "";}*Z ).rstr ip.gsu b(?x){ s<<V.t o_s(20 );s.sl ice!(/ S/)}; o.puts (y<14? l:l[0. .-4]+" ~))")} ;o.put s})*"" ));;%~ 7h7hhf 1j626e 0dh6392fa6b6b45iid c59c7h7hhf1j626e0d h6392fa6b6b45iidc5 9c7h7hhf1j626e0dh6 392fa6b6b45iidc59c 7h7hhf1j626e0dh639 2fa6b6b45iidc59c7h 7hhf1j626e0dh6392f a6b6b45iidc59c7h7h hf1j626e0dh6392fa6 b6b45iidc59c7h7hhf 1j626e0dh6392fa~)) by Yusuke Endoh
  • 14. Demo
  • 15. Key TRICKs / Exploits • Quine • formatting code • cheat OCR • calculating Elo Rating • abuse of -i eval$s =(%q(;eval((%w(Z=" s"*2;V="1sj6w3u1i kfyikb6y01xsjdceda j4".to _i(36);R=0..9;a,b= [[*$s.lines],[*$<] ].map{|s|n=0;1.ste p(w=s. map{|l|l.chomp.siz e}.max,2+3*m=48/(w -70)){|x|n=n*10+R. find{|n|R.al l?{|i| V[n*15 +i]<1= =Z<(s[ i/3*3+ 1][i%3*m+x]| |Z)}}} ;n};d= 10**(( b-a)/4 e2);[[ STDOUT,a+d=d *32/(d +1)],[ $stdou t,b-d] ].map{ |o,n|; s="eval$s=(%q("+$s [/(.*? ~){3}/ m];15. times{ |y|l=" %d"%(n+0.5);l=(l.b ytes.m ap{|c| (0..2) .map{| x|"xs "[V[c*15-720+y/3*3 +x]]*( 24/l.s ize)}* "";}*Z ).rstr ip.gsu b(?x){ s<<V.t o_s(20 );s.sl ice!(/ S/)}; o.puts (y<14? l:l[0. .-4]+" ~))")} ;o.put s})*"" ));;%~ 7h7hhf 1j626e 0dh6392fa6b6b45iid c59c7h7hhf1j626e0d h6392fa6b6b45iidc5 9c7h7hhf1j626e0dh6 392fa6b6b45iidc59c 7h7hhf1j626e0dh639 2fa6b6b45iidc59c7h 7hhf1j626e0dh6392f a6b6b45iidc59c7h7h hf1j626e0dh6392fa6 b6b45iidc59c7h7hhf 1j626e0dh6392fa~))
  • 16. %~ 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa~ ) ) eval$s=(%q(;eval ( ( %w( Z="s"*2;V="1sj6w3u1ikfyikb6y01xsjdcedaj4".to_i(36); R=0..9; a,b=[[*$s.lines],[*$<]].map{|s| n=0; 1.step(w=s.map{|l|l.chomp.size}.max,2+3*m=48/(w-70)){|x| n=n*10+R.find{|n| R.all?{|i| V[n*15+i]<1==Z<(s[i/3*3+1][i%3*m+x]||Z) } } }; n }; d=10**((b-a)/4e2); [ [STDOUT,a+d=d*32/(d+1)], [$stdout,b-d] ].map{|o,n| ;s="eval$s=(%q("+$s[/(.*?~){3}/m]; 15.times{|y| l="%d"%(n+0.5); l=(l.bytes.map{|c| (0..2).map{|x| "xs"[V[c*15-720+y/3*3+x]]*(24/l.size)}*""; }*Z).rstrip.gsub(?x){s<<V.to_s(20); s.slice!(/S/) }; o.puts(y<14?l:l[0..-4]+"~))") }; o.puts})*"" ) );; %~ 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh6392fa6b6b45iidc59c Dissection Calculate Elo Rating Output code to OCR Fillers
  • 17. “Worst Abuse of Constants” def _(&b)$><<->(x){x ? (String===x ?x.upcase: (Class===x ? x : x.class).name[$a?0:($a=5)]): " "}[ begin b[];rescue Exception;$!;end ] end _ { return } _ { method(:p).unbind } _ { eval "{ " } _ { Thread.current.join } _ { nil } _ { select } _ { ruby } _ { self.class } _ { Thread.current.group } _ { nil.to_h } _ { "xFF".encode("big5") } _ { raise } _ { [0][1] } _ { Regexp.compile "*" } _ { RUBY_COPYRIGHT[32] } _ { binding } _ { :s.class.name[1] } _ { warn } _ { [a: :b][0] } _ { methods } _ { IO.class } _ { {}.fetch(0) } _ { open " " } _ { 1000000.chr } by Yutaka Hara Dishonarable Mention
  • 18. Demo
  • 19. Key TRICKs / Exploits • Ruby Constants • $! def _(&b)$><<->(x){x ? (String===x ?x.upcase: (Class===x ? x : x.class).name[$a?0:($a=5)]): " "}[ begin b[];rescue Exception;$!;end ] end _ { return } _ { method(:p).unbind } _ { eval "{ " } _ { Thread.current.join } _ { nil } _ { select } _ { ruby } _ { self.class } _ { Thread.current.group } _ { nil.to_h } _ { "xFF".encode("big5") } _ { raise } _ { [0][1] } _ { Regexp.compile "*" } _ { RUBY_COPYRIGHT[32] } _ { binding } _ { :s.class.name[1] } _ { warn } _ { [a: :b][0] } _ { methods } _ { IO.class } _ { {}.fetch(0) } _ { open " " } _ { 1000000.chr }
  • 20. Dissection def _(&b) $><< ->(x){ x ? (String === x ? x.upcase : (Class===x ? x : x.class).name[$a?0:($a=5)]) : " " }[ begin b[] rescue Exception $! end ] end _ { return } _ { method(:p).unbind } _ { eval "{ " } _ { Thread.current.join } _ { nil } _ { select } _ { ruby } _ { self.class } _ { Thread.current.group } _ { nil.to_h } _ { "xFF".encode("big5") } _ { raise } _ { [0][1] } ... • $><< to replace “puts” • === • [] to execute block • $! to return Exception
  • 21. “Most Classic” pack"C*"); puts(l)}}};M= Math);S=%: Jesu, Joy of Man's Desiring Johann Sebastian Bach # | # | # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # | | | # | #| # # # | # | | | # | | # # # # # # | | # | | | # # # # # # | | | # | | # # # # # | | # | | # # | # # # # | | | # | | # # # # # #
  • 22. | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # | | | # | #| # # # | # | | | # | | # # # # # # | | # | | | # # # # # # | | | # | | # # # # # | | # | | # # | # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | # | | # # # # # # | | | #
  • 23. | | | # | # | # # # # # | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | : by Yusuke Endoh BRO NZE
  • 24. Demo
  • 25. Key TRICKs / Exploits • Quine + music box • Frequency modulation synthesis • Uses sound server e.g. PulseAudio
  • 26. Dissection Do I have to explain everything? Can’t you just be amazed?
  • 27. “Most Readable” begin with an easy program. you should be able to write a program unless for you, program in ruby language is too difficult. At the end of your journey towards the ultimate program; you must be a part of a programming language. You will end if you != program by Shinichiro Hamaji SILV ER
  • 28. Demo
  • 29. Key TRICKs / Exploits • begin .. end if false • for statement for defining variables begin with an easy program. you should be able to write a program unless for you, program in ruby language is too difficult. At the end of your journey towards the ultimate program; you must be a part of a programming language. You will end if you != program
  • 30. Dissection begin with(an(easy(program.you(should(be(able(to(write)))))))) unless (for you, program in ruby(language(is)) do too(difficult.At(the)) end) a(program()) end of(your(journey(towards(the)))) ultimate(program) you(must) be(a(part(of(a(programming))))) language.You(will) end if (you != program) whitequark/parser mbj/unparserAST begin with an easy program.you should be able to write a program unless for you, program in ruby language is too difficult. At the end of your journey towards the ultimate program; you must be a part of a programming language. You will end if you != program
  • 32. Demo
  • 33. What’s a Pangram • a sentence using every letter of the alphabet at least once
  • 34. Key TRICKs / Exploits • Contains & Prints ASCII Character from 0x20 to 0x7e exactly once • 0x2016 = 3210 … 0x7e16 = 12610 • !"#$%&'()*+,- ./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRS TUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}~
  • 35. Key TRICKs / Exploits • 32.upto(126){|x| putc x} • $. • 3_0 = 30 • Escape quotes as ” and ?’ and :`
  • 36. !@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz&[%r{"}mosx,4>6]|?'while(putc 3_0-~$.+=9/2^5;)<18*7and:`# Dissection 3_0-~$.+=9/2^5;)<18*7 while ((putc(30 - (~($. += ((9 / 2) ^ 5)))) < (18 * 7)) && :`) ((!@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz) & [/"/mosx, (4 > 6)]) | "'" end Most Interesting Part $. => 1 # ruby golfer’s best friend
  • 37. Google Search Term: “trick 2013 rubykaigi” https://github.com/tric/trick2013