SlideShare a Scribd company logo
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

Scalaz
ScalazScalaz
Scalaz
mpilquist
 
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-toturial
Wayne Tsai
 
Practical scalaz
Practical scalazPractical scalaz
Practical scalaz
oxbow_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 usage
Wayne Tsai
 
Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)Jscex: Write Sexy JavaScript (中文)
Jscex: Write Sexy JavaScript (中文)jeffz
 
Deriving Scalaz
Deriving ScalazDeriving Scalaz
Deriving Scalaz
nkpart
 
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
Ruslan Shevchenko
 
Scala best practices
Scala best practicesScala best practices
Scala best practices
Alexander Zaidel
 
深入浅出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 languages
Jonas Follesø
 
computer graphics practicals
computer graphics practicalscomputer graphics practicals
computer graphics practicals
Manoj Chauhan
 
First-Class Patterns
First-Class PatternsFirst-Class Patterns
First-Class Patterns
John 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
 
Advance java
Advance javaAdvance java
Advance java
Vivek Kumar Sinha
 
Collection v3
Collection v3Collection v3
Collection v3
Sunil 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 algorithm
Kapil 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 tour
Simon Proctor
 
Perl6 a whistle stop tour
Perl6 a whistle stop tourPerl6 a whistle stop tour
Perl6 a whistle stop tour
Simon 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 programming
Lukasz 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# 7
Paulo Morgado
 
Javasccript MV* frameworks
Javasccript MV* frameworksJavasccript MV* frameworks
Javasccript MV* frameworks
Kerry 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
 
Operators
OperatorsOperators
Operators
Daman Toor
 
Java operators
Java operatorsJava operators
Java operators
Shehrevar Davierwala
 
An Intro To ES6
An Intro To ES6An Intro To ES6
An Intro To ES6
FITC
 
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
Ismar 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
 
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 ClojureDmitry Buzdin
 
Parsing JSON with a single regex
Parsing JSON with a single regexParsing JSON with a single regex
Parsing JSON with a single regex
brian 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

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
Jen Stirrup
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
Alex Pruden
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...The Metaverse and AI: how can decision-makers harness the Metaverse for their...
The Metaverse and AI: how can decision-makers harness the Metaverse for their...
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofszkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex Proofs
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

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