6. TRICK 2022 Judges
Yusuke Endoh (@mametter)
Koichiro Eto (@eto)
Shinichiro Hamaji (@shinh)
Yutaka Hara (@yhara)
Yukihiro Matsumoto (@yukihiro_matz)
Sun Park (@sunleonid)
Darren Smith
7. TRICK 2022 Judges
eto
– Media Artist.
– Senior Researcher at AIST.
shinh
– The admin of anarchy golf.
– IOCCC winner.
yhara – The author of Japanese esolang book.
matz – The creator of Ruby.
leonid – The 1st super Ruby golfer.
flagitious
– The author of GolfScript.
– Yet another super Ruby golfer.
– Full-time Ruby committer at Cookpad.
– The world’s No.1 IOCCC player.
mame
8. Submission statistics / Judging process
• Submission statistics
– Thank you for all the submitters!
• Judging process
– Each judge gives each entry a score of 1..10
– Any information about the authors is not read
• Awards
– Three medals
– Seven judges' awards
JP
US
DE
UK
9. CAUTION
• This talk has a lot of spoilers!
– Get out here if you want to enjoy analyzing the winners
• The winning entries will be published at:
No k!
http://github.com/tric /trick2022/
13. jimlock.rb
• Judges' comments
– mame: I like this kind of piece that would never have been written except for
TRICK.
– eto: Simple and nice.
mame award
“Most calculating”
14. Winner »
eto shinh yhara matz leonid flagitious mame score
“Most playable”
『最も遊べるで賞』
Don Yang
yhara award
7 4 7 6 4 7.5 5 5.79
17. omoikane.rb
• Snake game
– Game over if you hit an obstacle or your own body
– The snake grows longer if it eats food
• Originality
– The snake can toggle between black and white
– The snake can eat an item of his color
– Inspired by Ikaruga(斑鳩)
• A famous shooter video game with this scoring rule
• It does not use curses but io/console
yhara award
“Most playable”
18. omoikane.rb
• Judges' comments
– yhara: At first it looked just like a simple snake game but actually it has some
tweaks and many features to make the game enjoyable.
– shinh: It was a snake, not Python.
yhara award
“Most playable”
19. Winner »
eto shinh yhara matz leonid flagitious mame score
“Most likely to be required”
『最も必要となりそうで賞』
Yutaka HARA
flagitious award
7 3 N/A 6 5 8 6 5.83
20. yhara.rb flagitious award
“Most likely to be required”
︙
using Kumimoji
a = 1.㌢㍍
b = 10.㍉㍍
p a == b #=> true
puts a + b #=> 0.02㍍
㌢㍍
㍉㍍
Japanese "kumimoji"
(composite characters)
centi meter
milli meter
21. yhara.rb
• A DSL using "kumimoji" (composite characters)
– like 100.days of ActiveSupport
flagitious award
“Most likely to be required”
︙
a = 1.㌋
b = 1.㍄
printf "1㌋ ≒ %f㍄¥n", a/b
#=> 1㌋ ≒ 1.150779㍄
nautical mile
mile
22. yhara.rb
• Dare not obfuscate, but cleanly implement with meta-programming
• Attention to detail
flagitious award
“Most likely to be required”
%w(
1 ㌅ = 2.54 ㌢㍍
1 ㌳ = 30.48 ㌢㍍
...
).each_slice(5) do |_, name, _, amount, unit|
define_method name do
amount.to_r.send(unit)
end
end
alias ㌖ ㌔㍍
meter
kilo
kilometer
(in a character)
23. yhara.rb
• Judges' comments
– flagitious: I'd like to encourage non-obfuscated entries in the future that none
the less become confusing for high complexity or other oddities. And I
thought it was well done.
– eto: Practical, even! Attempting to use Unicode characters in a practical
way is fun, just like APL.
– shinh: Is this just normal code?
– yhara (camouflage comment): It's interesting that 1 Kairi is so close to 1 Mile
flagitious award
“Most likely to be required”
24. Winner »
eto shinh yhara matz leonid flagitious mame score
“Most reactive and diffusive”
『最も反応的かつ拡散的で賞』
Sergey Kruk (lonelyelk)
matz award
9 6 5 8 7 7 6 6.86
25. lonelyelk.rb matz award
“Most reactive and diffusive”
$q=%w[$w&&!$s&&exit;W=130;H=80;HS=40;puts(q="$q=%w[#$q].join;at_exit{eval($q)}".chars.each_slice(W).map(&:join).join("¥n"));$s&&$w
&&(puts('$w="'+$w+?"+";at_exit{$s=#$s}¥n#{q}")||exit);srand($s||=Random.new_seed);f=0.03+0.03*rand;k=0.057+0.006*rand;g=32.chr+".:
-=+*#%@";mc=800+400*rand;spt=(1..(3+5*rand)).map{{x:(W*rand).floor,y:(H*rand).floor,r2:(10+10*rand)**2}};z=(0...H).map{|y|(0...W).
map{|x|{a:1.0,b:spt.any?{|s|s[:r2]>=(x-s[:x])**2+(y-s[:y])**2}&&1.0||0.0}}};n=(1..H).map{(1..W).to_a};$l=->(v,x,y,s){(l=x-1)<0&&l=
W-1;(r=x+1)>=W&&r=0;(t=y-1)<0&&t=H-1;(b=y+1)>=H&&b=0;0.2*(v[y][r][s]+v[y][l][s]+v[t][x][s]+v[b][x][s])+0.05*(v[t][r][s]+v[t][l][s]
+v[b][r][s]+v[b][l][s])-v[y][x][s]};print('$w="');pc=4;mc.to_i.times{|c|(0...W).map{|x|(0...H).map{|y|la=$l.call(z,x,y,:a);lb=$l.c
all(z,x,y,:b);a=z[y][x][:a];b=z[y][x][:b];n[y][x]={a:(a+1.0*la-a*b*b+f*(1-a)).clamp(0,1),b:(b+0.5*lb+a*b*b-(k+f)*b).clamp(0,1)}}};
z,n=[n,z];((c+=1)/mc*W).floor>pc&&(pc+=1)&&print(?.)};puts(?.*(W-pc));dmi,dma=z.map{|l|l.map{|v|v[:a]-v[:b]}.minmax}.flatten.minma
x;z.each_slice(H/HS){|l|W.times{|x|sum=l.inject(0.0){|a,l|l[x,1].inject(a){|s,v|s+((v[:a]-v[:b]-dmi)/dma)}};print(g.chars[(sum*W*H
S*g.size/(W*H)).clamp(0,g.size-1).floor])};puts};ft=?"+";at_exit{$s=#$s}";puts(?.*(W-ft.size)+ft+10.chr+q)].join;at_exit{eval($q)}
30. lonelyelk.rb
• Reaction-Diffusion System
– A mathematical model of patterns like giraffes, cheetahs, fishes, etc.
– Simulates reaction and diffusion of chemical substances
• … and Quine
– It shows itself twice, at the top and at the bottom
– All the following commands work well
matz award
“Most reactive and diffusive”
$ ruby entry.rb
$ ruby entry.rb | ruby
$ ruby entry.rb | head | ruby
$ ruby entry.rb | tail | ruby
31. lonelyelk.rb
• Judges' comments
– matz: I love this kind of thing.
– eto: Very beautiful.
– flagitious: Impressive evolving rendering quine.
matz award
“Most reactive and diffusive”
32. Winner »
eto shinh yhara matz leonid flagitious mame score
“Most global”
『最もグローバルで賞』
Yusuke Endoh
eto award
9 8 8 5 8 9 N/A 7.83
36. mame.rb
• Q. What is the difference from Endoh's work?
• A. Many new features and improvements!
– The tilted rotational axis (23.4 degrees!)
– Very compressed polygon map data (only 286 letters!)
– Robust spherical trigonometry
– Map dump with a mark of specified lat/long
eto award
“Most global”
39. mame.rb
• Judges' comments
– eto: Earth! High artistic point. It contains polygon data of the world map. Very
interesting.
– shinh: The compression ratio looks amazing. I think there is enough
difference from "Qlobe".
– mame (camouflage comment): It is almost the same as my "Qlobe", but there
seems to be enough novelty in the technical aspect.
eto award
“Most global”
40. Winner »
eto shinh yhara matz leonid flagitious mame score
“Most accessible”
『最もアクセシビリティがある賞』
Yutaka HARA
leonid award
8 6 N/A 9 10 8 8 8.00
42. yhara.rb
• The braille part is a symbol and method chain
• This braille part represents the main code
– Eight-dot braille represents a byte (8-bit) sequence
leonid award
“Most accesible”
:⠥⠥⠥ … ⡖⡭⡂.
⠼⡜⡜⠒ … ⡻⡺⡽.
⠓⡻⠥⠥ … ⠼⡝⠒.
︙ ︙
⠸⠐⠘⡖ … ⡶⠐⡚⠠
Symbol's colon Symbol's body method call's period
method
name
43. yhara.rb
• Judges' comments
– eto: Cool animation that the dots appear slowly. It's unprecedented as the
beauty of the source code.
– shinh: Very impressive.
– mame: Abuse of Braille!
leonid award
“Most accesible”
44. Winner »
eto shinh yhara matz leonid flagitious mame score
“Most orderly code”
『最も整然としたコードで賞』
Tomoya Ishida (tompng)
shinh award
7 10 10 7 8 9.5 9 8.64
45. tompng.rb shinh award
“Most orderly code”
rule = $*[00]&.to_i || 30
h ||= $*[01]&.to_i || 32
[ % if % TRICK-2022 %% %]
# ] if a /%{(?<a>)/ =~ %} if + %} - %[
# } if b /%<(?<b>)/ =~ %> if - %> + %{
# > if c /%+(?<c>)/ =~ %+ if + %+ - %<
# + if d /%-(?<d>)/ =~ %- if - %- + %+
# - if e f, g, h, / =~ %/ if def e(f, g, h, *) =
# + if d /%-(?<d>)/ =~ %- if g.map! do rule.[] _1.join.to_i 2 end.!
# > if c /%+(?<c>)/ =~ %+ if !(g = *[g[-1], *g, g[0]].each_cons(3))
# } if b /%<(?<b>)/ =~ %> if puts(g.join.tr '01', ' #') || h > 0 &&
# ] if a /%{(?<a>)/ =~ %} if !g ||= [*g = [0] * h, 1] + g if h -= 1
eval(File.read f ||= __FILE__)
47. tompng.rb
• It is very difficult to read this piece
• The main TRICK:
– If a local variable x is defined, it is a division
– If a local variable x is not defined, it is a method call
shinh award
“Most orderly code”
x /y #/
x(/ y #/)
x / y #/
48. tompng.rb
• A simplified version
shinh award
“Most orderly code”
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
method call
regexp
(and defines a) string literal string literal
49. tompng.rb
• A simplified version
– This executes "code1" and reloads itself
– Note that a local variable "a" is now defined!
shinh award
“Most orderly code”
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
50. tompng.rb
• With a local variable "a" defined
shinh award
“Most orderly code”
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
string literal string literal
comment
division
51. tompng.rb
• When a local variable "a" defined
– Execute "code2"
• This code executes "code1" and then "code2" as a whole
shinh award
“Most orderly code”
a /%!(?<a>)/ =~ %! if + %! - %[
#! if (code2; exit)
#] if (code1; false)
eval(File.read($0))
52. tompng.rb shinh award
“Most orderly code”
rule = $*[00]&.to_i || 30
h ||= $*[01]&.to_i || 32
[ % if % TRICK-2022 %% %]
# ] if a /%{(?<a>)/ =~ %} if + %} - %[
# } if b /%<(?<b>)/ =~ %> if - %> + %{
# > if c /%+(?<c>)/ =~ %+ if + %+ - %<
# + if d /%-(?<d>)/ =~ %- if - %- + %+
# - if e f, g, h, / =~ %/ if def e(f, g, h, *) =
# + if d /%-(?<d>)/ =~ %- if g.map! do rule.[] _1.join.to_i 2 end.!
# > if c /%+(?<c>)/ =~ %+ if !(g = *[g[-1], *g, g[0]].each_cons(3))
# } if b /%<(?<b>)/ =~ %> if puts(g.join.tr '01', ' #') || h > 0 &&
# ] if a /%{(?<a>)/ =~ %} if !g ||= [*g = [0] * h, 1] + g if h -= 1
eval(File.read f ||= __FILE__)
rule = $*[00]&.to_i || 30
h ||= $*[01]&.to_i || 32
[ % if % TRICK-2022 %% %]
# ] if a /%{(?<a>)/ =~ %} if + %} - %[
# } if b /%<(?<b>)/ =~ %> if - %> + %{
# > if c /%+(?<c>)/ =~ %+ if + %+ - %<
# + if d /%-(?<d>)/ =~ %- if - %- + %+
# - if e f, g, h, / =~ %/ if def e(f, g, h, *) =
# + if d /%-(?<d>)/ =~ %- if g.map! do rule.[] _1.join.to_i 2 end.!
# > if c /%+(?<c>)/ =~ %+ if !(g = *[g[-1], *g, g[0]].each_cons(3))
# } if b /%<(?<b>)/ =~ %> if puts(g.join.tr '01', ' #') || h > 0 &&
# ] if a /%{(?<a>)/ =~ %} if !g ||= [*g = [0] * h, 1] + g if h -= 1
eval(File.read f ||= __FILE__)
main part
executed in
reverse order
53. tompng.rb
• Judges' comments
– shinh: Ruby is Lisp-2 but not Lisp. This piece makes good use of this fact.
I like it.
– yhara: Definitely the hardest to read.
– flagitious: Cool cellular automaton based on parsing trick, no eval abuse,
short.
– mame: Amazing obfuscation unique to Ruby!
shinh award
“Most orderly code”
61. • The TRICK for left gravity
• The TRICK for upward gravity
“Most anti-gravity”
mame2.rb
"¥ #{code1}
# {code2}"
"¥#{code1}
#{code2}"
left
gravity
"x
x#{code1}
xx{code2}
"
"x{code1}
x#{code2}
xx
"
upward
gravity
62. • Judges' comments
– shinh: Various things by gravity. Wow, it's so fun!
– yhara: Very tricky - essentially five programs are condensed into one.
– flagitious: My brain hurts, horizontal/vertical is a bit of a gimmic (not generic,
but still)
– mame (camouflage comment): I think this piece would be the most difficult to
implement in TRICK 2022
“Most anti-gravity”
mame2.rb
67. • A fractal organism with a pulse
– You can tweak it with a mouse click
• No JavaScript, no canvas, no HTML5!
• Pre-HTML5 technologies
– Endless streaming of an animated GIF
– <input type="image">
• This element tells the click position to the server
with a GET request like /?x=50&y=100
“Most interactive code”
tompng2.rb
69. • Judges' comments
– eto: Heart-shaped code. It is very beautiful.
– shinh: Sending GIF stream is interesting. The author should advocate ARAG
(Async Ruby and Gif) instead of AJAX (Async JS and XML).
– yhara: Good example of how Ruby is good at network programming. It reacts
to mouse click, wow!
– flagitious: Cool that it is interactive.
“Most interactive code”
tompng2.rb
72. • 960-frame fishbowl animation
– Each frame is an executable Ruby code (Quine)
• The animation does not insert whitespaces
• But it replaces some characters with whitespace
– Not trivial to restore the original code
“Best fishbowl”
tompng3.rb
73. • Error-correcting codes with linear algebra
• By using Matrix library
– with monkey-patching Integer for modular arithmetic
• Wait! May this error-correcting code be corrupted?
“Best fishbowl”
tompng3.rb
require 'matrix'
matrix = Matrix[[3, 1, 4], [1, 5, 9], [2, 6, 5]]
class Integer
def quo(x) = self * x.pow(87, 89) % 89
def abs() = [self % 89, 89 - self % 89].min
end
answer = matrix.lup.solve([1, 2, 3])
(matrix * answer).map { _1 % 89 }
76. “Best fishbowl”
tompng3.rb
eval((s=%~c=(0..35
).map{s[2*_1+1]}*'';class$Inte
ger;def$quXinclude(Math ;spXo(a)=self*
a.pow(87X=h=32.chr;g=PI/480;ls=(sp*31X,89)%89;
def$abX+'eval((s=%'+(n=? .next)+s*88.chr+[nXs()=[a
=self%X+'.split(',sp*25+'?'+88.chr+');(0..36).mapX89,89-
a].miX{s[2*_1].split}',sp*31+".join.tr('$',$/)))"]*$/)Xn;end
;reqX.split$/;trap(:INT){puts;exit};q=->t,i{a,y=((t+i*99)Xuire
'matrX%960). ivmod(80);[(a*(7+i)+i*23)%79+(y+a)/(5+i%4)%2,39Xix';1
5.tiX-y/2]};p=->t,u{a=->b,c{(0..5).sum{(u%2-1)*E**(t*(b+c*_1)*gXmes{
|i,*X.i+ i*u+=5+sin(u*u))}};x,z=a[5,3]. 5,3].rect;x+=y.Xv|z=
*?!Xi a[19,4];z+=w;r=(4+(x.abs+z.i).ab };t=(0..959).fX..?
W,?Xind{|t|(0..29).all?{x,y=q[t,_1];(x 2||h=ls[y][x]X[,*
?]..X[/[^!-}]/]}};h=($**h+h).chr;eval( []} ->(x,yX?};a
=(0X,a,b){x=x*36+39.5;y=19.5-y*18;b*=1 |i|((yX..1
34)X-b).ceil..y+b).map{|j|((x-i)/a+(y j)/ .times{X.ma
p{zXx,z=p[t,_1];l=u```=0;while``````(l<1)``; u+```=0 ;d=x-y;X.in
dex(Xl+=(d.abs+(z-w``)``.i).ab``s*1.``1 ;x``,z=y``,w;o[v``=``x.r d.imag/Xc[i+
15*Xd.abs*l*sin(2*``l-t``*g*80``-_1) l*(``1-l)/``6,a``=l*( -l)**2*0.X_1]
)};X7,a*2]&&o[v,z,``0.0``3,l**`` ``times``{|i``|(8+i).times{|Xw=*
MatXj|o[sin(i)/2+````` ```sin( `/2.0`````````)*j/200,j*0.0Xrix
[*(X5-1,0.02,0.1]``}} ``. q[t,``_1];m``[y][x]= };i=-X0..
44).X1;$><<(['%%','[H .map{|j|(0..79).map{|k|x=(Xmap{
|i,X -39.5)/35.8;y=( i+=1;m[j][k]?h:c[i]):ls[j]X*b|
v<<X[k];}*''}*$/<<0) 1)%9 te"`")#iJw6$Dcc1]r*G"eDXa.z
ip(X%P<M^Az!7?f*yxM `d"qi77UD*T!: .^B][T ?%:"w82/s3A[M]V %KbeX0..
).suX5,G_=6D65#,zMaW $lsR=!Uvhio zb : dE:50obh|RgCTFfy*+)Xm{-(
p=(XH0},JA>;rxRht+ ADjV;e&'/h Qg cO?,C%J a0mE+Qy2a9'X(i+
_2)X^):t|am}b`k>e zxd[HJ9 ony JC gucaew/gcoWRy_X**9
.1).X*]u+DL(&hH wc 8531x'b bd= } < z Say vJ@{?+$Xto_i
%88+XV-GE'5^Va <9 *`?9b1 >_ } 8g 3 4 l zH_/o@j*2vX1)*(
_1||(Xp]h"u=4- U. 0nz2- E9U #"pl=^ e E(=+x6s/pXb<<p;
0))}X3t_@K?C C& ^6(BE > K 2DA B8jDlS b* WpM(|t(2X;b}]
.lup.X5R(B71 la u?5V? M(2 dP <S<,fo Qv >Fj4<?KXsolve
(v);13X"$; wL b,l^f$ f,5 z R,PhV# pM w^7UX5.time
s{c[i+X (8 NfbKS) 2*` I RW7zgh!P j6 tX15*_1]
=z[a[_1]X enuc,T= Oi. > 5D=#(;(% ?X||w.shif
t]}};eval(X9P lRQ S dq4M(Xc)~.split(
?X);(0..36).map{s[2*_1].split}
.join.tr('$',$/)))
Error-correcting code is here!
(Fish don't come to this area)
The main code is inside
with redundancy for
error recovery
77. • Judges' comments
– eto: Beautiful! The "AQUA" Logo is also good!
– shinh: Self-repairing Quine is not new, but this one is moving and catchy!
– flagitious: Extremely aquatic and beautiful, I haven't figured out how fishes
are calculated yet.
– mame: Beautiful animation. Error correction makes the animation more
beautiful. I love that the technical side supports the artistic side.
“Best fishbowl”
tompng3.rb
81. Prize?
• Dishonor: the title of “insane”
• Top three entries will be checked into
the Ruby official repository in “sample” directory
– Ruby 3.2.0 will have them
82. Conclusion
• The winning entries will be published soon at:
• Thank you for all participants!
No k!
http://github.com/tric /trick2022/
83. Next contest?
• No plan!
– TRICK 2013
– TRICK 2015
– TRICK 2018
– TRICK 2022
– TRICK ?
See you again!
+2
+3
+4
+?