TRICK2013 Results
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
4,860
On Slideshare
4,710
From Embeds
150
Number of Embeds
4

Actions

Shares
Downloads
3
Comments
0
Likes
7

Embeds 150

http://eventifier.co 100
https://twitter.com 47
http://eventifier.com 2
http://d.hatena.ne.jp 1

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. TRICK 2013 ResultsTRICK judges:@mametter, @eto, @shinh, @yhara,@yukihiro_matz, leonid, @eban
  • 2. What’s “TRICK”• A contest for esoteric Ruby programmingRuby で変態度を競い合うプログラミングの祭典cf. International Obfuscated C Code Contest (IOCCC)• This talk dishonors the winners of TRICK 2013本発表では TRICK 2013 入賞者の不名誉を讃え• And demonstrates the winning entriesさらに入賞作品のデモを紹介します
  • 3. About the TRICK
  • 4. What “TRICK” meansTranscendental Ruby Imbroglio Contest for RubyKaigi• Transcendental /ˌtransɛnˈdɛnt(ə)l/– “relating to a spiritual realm”「霊界に関する」– but it is translated as “unworldly technical” in Japaneseなぜか日本語では「超絶技巧」と訳される• ex. Transcendental Etudes (超絶技巧練習曲、Liszt)• Imbroglio /ɪmˈbrəʊlɪəʊ/– “an extremely confused, complicated, or embarrassingsituation”極めて混乱した、複雑で、厄介な事態 adapted fromOxford Dictionaries OnlineNamed by leonid
  • 5. Goals of the TRICK• Write the most Transcendental, Imbroglio Ruby program現世利益のない、意味不明な Ruby プログラムを書く• Illustrate some of the subtleties (and design issues) ofRubyRuby のある種の神秘性 (と仕様バグ) を明らかにする• Show the robustness and portability of Ruby interpretersRuby 処理系の意外な堅牢性と移植性を示す• Stabilize the spec of Ruby by the presence of valuable butunmaintainable codeメンテナンス不能だが価値あるコードを世に放つことで Ruby の仕様を安定化する
  • 6. Related Contests• IOCCC: International Obfuscated C Code Contest• UCC: Underhanded C Contest• OPC: Obfuscated Perl Contest• IORCC: International Obfuscated Ruby Code Contest1990 1995 2000 2005 2010 2013CPerlRuby1985IOCCC 1984-2006 2011 2012UCC 2005-2009 2013OPC 1996-2000IORCC 2005 2012?TRICK2013
  • 7. TRICK Contest Rules (1)1. Your entry must be a complete Ruby program.あなたの作品は単体で動作する Ruby プログラムでなければならない。2. The size of your program must be <= 4096 bytes inlength. The number of non-space characters must be <=2048. The total size of your compressed submissionmust be less than ten megabyte in size.あなたのプログラムのサイズは 4096 バイト以下でなければならない。非空白文字の数は 2048 以下でなければならない。あなたの投稿は zip全体で 10 MB 未満でなければならない。3. You can submit multiple entries, and your team mayconsist of any number of members.あなたは何作でも作品を投稿できる、また、あなたのチームは何人であっても良い。
  • 8. TRICK Contest Rules (2)4. The entirety of your entry must be submitted underMIT License.あなたの作品全体は MIT ライセンスで投稿されなければならない。5. Your entry must bring the judges a surprise,excitement, and/or laughter.あなたの作品は審査員に驚き、感動、(and/or)笑いを与えなければならない。• Meta Rule: Rule Golf– Too many restrictions may inhibit creativityあれこれ制約して作品の可能性を絞らないように
  • 9. Guidelines (1): Ruby version/impl.• Matz Ruby Implementation (MRI) 1.9/2.0 isrecommended.MRI 1.9/2.0 で動くことを推奨• MRI 1.8 is highly discouraged because your entrywont work in near future.1.8 でしか動かないコードは強く非推奨• You can use implementations other than MRI, such asJRuby and Rubinius.MRI 以外の実装もOK
  • 10. Guidelines (2): Library• You can require a gem library.gem 使って OK• But note that we will expect such entries to be muchmore interesting than an entry that uses no library;hence we will judge them strictly.ただしその分面白い作品であることが期待され、審査基準は厳しくなる• It is highly discouraged to abuse gem to get aroundthe size limit.サイズ制限を回避するために gem を使うのは強く非推奨
  • 11. Guidelines (3): Misc.• The judges would prefer more stoic, more portable,and/or more funny entries.ストイックで、様々な環境で動き、笑いのある作品が評価されやすい• You are encouraged to examine the winners ofprevious IOCCC contests.過去の IOCCC の勝者を研究することを推奨する• To judge without bias, we will try to keep each entryanonymous during judgment. Do not includeanything that reveal your identity (such as a signature,copyright, URL, etc.) in your program.偏見なく審査できるよう、審査の間はすべての作品を匿名として扱うので、プログラムに作者がわかるような情報を含めないこと
  • 12. JudgesYusuke Endoh (@mametter)Koichiro Eto (@eto)Shinichiro Hamaji (@shinh)Yutaka Hara (@yhara)Yukihiro Matsumoto (@yukihiro_matz)Sun Park a.k.a. leonidHirofumi Watanabe (@eban)
  • 13. Judges• mame• eto• shinh• yhara• matz• leonid• eban– IOCCC winner– Advocate for Transcendental programming.– Media Artist.– Chairman at NicoNicoGakkai Beta.– The admin of anarchy golf.– IOCCC winner.– The author of Japanese esolang book.– The creator of Ruby.– The 1st super Ruby golfer in the anarchy golf.– Ruby committer.– The 2nd super Ruby golfer in the anarchy golf.
  • 14. PR: Yusuke Endoh (@mametter)• まじめな翻訳書
  • 15. PR: Koichiro Eto (@eto)• 「進化するアカデミア」• ジュンク堂でも発売中– サインします
  • 16. PR: Yutaka Hara (@yhara)• 「Rubyで作る奇妙なプログラミング言語」Making EsotericLanguage with Ruby• 2013年秋~冬電子化(+復刻!?)予定
  • 17. Judging process• Each judge scores each entry on 10 point scale各審査員は各作品を 10 点満点で評価– Each entry gains the average平均点がスコア• A judge has no right to score his own entry自分の作品は審査対象外• Judges keep each entry anonymous during judgment審査員は作者を知らずに審査する
  • 18. The winning entries of TRICK 2013
  • 19. Summary• 10 winning entries入賞作品数: 10– including “Top Four” for particularly high dishonors上位4作品は特に不名誉を受ける• Winning entries will be pushed automatically入賞作品は時間になったら push されますhttp://github.com/tric /trick2013/DishonorablementionNo k!
  • 20. “Good way to make programswonderful”Winner:mame leonid yhara eban shinh eto matz4 6 6 5 6 5 6baban5.4314:45:00 ← push 予定時刻
  • 21. “Good way to make programswonderful”CONTEXT=->{Alice.in.wonderland.___Alice.was.beginning_to.get.very._tired.of.her.sitting.by.her.sister.on.the.bank,and_.of.having.nothing.to.do,once.or.twice.she.had.peeped.into.the.book.her.sister.was.reading...
  • 22. “Good way to make programswonderful” – spoiler• Main trick: method_missing• Eye-catching feature: Character status----------------------------------------character status----------------------------------------Alice : tired line:5Alice : hear line:14Alice : feet line:19Alice : pop_down line:21WhiteRabbit : ran line:12WhiteRabbit : say line:15
  • 23. “Most characteristic”Winner:mame leonid yhara eban shinh eto matz7 8 7 1 9 7 1yoshi-taka5.7114:48:30 ← push 予定時刻
  • 24. “Most characteristic”# coding: utf-8%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%def%Flipping Storm! (╯°□°)╯︵ ┻━end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%defprintend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%(以下掲載不能)
  • 25. Execution result in os x
  • 26. “Most characteristic” – spoiler• Main trick: unicode phishing– ‘NO-BREAK SPACE’ (U+00A0)– ‘MINUS SIGN’ (U+2212)– ‘RIGHT-TO-LEFT EMBEDDING’ (U+202B)• Extra tricks:– %%%%%%%– Here document– ß with ss– Variable declaration by using defined?– Weird remarks• Down point: harmful output
  • 27. “Ruby by Ruby for Ruby award”Winner:mame leonid yhara eban shinh eto matz6 7 N/A 5 8 7 5Yutaka Hara (judge)5.8314:52:00 ← push 予定時刻
  • 28. “Ruby by Ruby for Ruby award”...def RubyRUBY::Ruby.ruby{|ruby|(ruby == :Ruby!) ? Ruby::RUBY :ruby.ruby.ruby.ruby.ruby{|ruby, _Ruby|(Ruby[_Ruby] == ruby) ? (2**_Ruby) : 0}.RUBY(:+)}.ruby{|ruby| @@ruby[ruby]}enddef ruby(ruby)ruby.Ruby(Ruby::Ruby).ruby{|ruby, _Ruby|_Ruby == "Ruby" ? ruby : -ruby}.ruby{|ruby|(ruby + RUBY::RUBY).ruby}._Rubyend...
  • 29. “Ruby by Ruby for Ruby award” –spoiler• Main trick: aliasing• Extra tricks:– A method name “ruby” and variable name “ruby” coexist– Dynamic typing hellalias RUBY inject; alias _Ruby join; endclass Fixnum; alias ruby chr; endclass Symbol; alias ruby to_s; endclass String; alias ruby chars; endclass Enumerator; alias ruby with_index; endclass Class; alias ruby new; endalias ruby puts
  • 30. “Worst house of garbage”Winner:mame leonid yhara eban shinh eto matz7 7 8 3 2 8 9Nakamura Narihiro6.2914:55:30 ← push 予定時刻
  • 31. “Worst house of garbage”GC.disableTape = ObjectSpaceOmitted because of normal appearance見た目はつまんないので省略Just a brainfuck interpreter, but…ただの brainfuck インタプリタです、が
  • 32. “Worst house of garbage” – spoiler• Main trick: abuse of ObjectSpace.each_object• By exploiting this infinite loop, a brainfuck interpreteris constructedこの無限ループを利用して brainfuck 評価器を構成している• Extra trick: history optionobjyield!object spaceobj objnewobjnewobjyield! yield! yield! yield!newobj
  • 33. “Best way to return true”Winner:mame leonid yhara eban shinh eto matz6 6 7 5 10 9 2NAKAMURA Usaku6.4314:59:00 ← push 予定時刻
  • 34. “Best way to return true”• The whole code$ruby.is_a?(Object){|oriented| language}
  • 35. “Best way to return true”— spoiler• Just executable, no feature at all実行可能なだけ、一切の機能なしIs the most Transcendental, Imbroglio Ruby program現世利益のない、意味不明な Ruby プログラムである• Exploits the fact that a method does not check if itaccepts block argument or notメソッドがブロック引数を受け付けるかどうかをチェックしないことを悪用• Reveals a spec-level bug: missing is_an?is_an? がないという仕様バグを浮き彫りにShows some of the subtleties (and design issues) ofRubyRuby のある種の神秘性(と仕様バグ) を明らかにしている
  • 36. “Best way to return true”— spoiler• Works on almost all Ruby implementationsほぼすべてのRuby実装で実行可能shows the robustness and portability of RubyinterpretersRuby 処理系の意外な堅牢性と移植性を示している• This code returns true$ruby.is_a?(Object){|oriented| language}
  • 37. “Most competitive”Winner:mame leonid yhara eban shinh eto matzN/A 7 8 6 4 7 8Yusuke Endoh (judge)6.6715:02:30 ← push 予定時刻
  • 38. “Most competitive”• Yusuke Endoheval$s =(%q(;eval((%w(Z=" ¥s"*2;V="1sj6w3u1i kfyikb6y01xsjdcedaj4".to _i(36);R=0..9;a,b= [[*$s.lines],[*$<] ].map{|s|n=0;1.step(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|"x¥s "[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.slice!(/ ¥S/)}; o.puts (y<14? l:l[0. .-4]+"~))")} ;o.put s})*"" ));;%~ 7h7hhf 1j626e0dh6392fa6b6b45iid c59c7h7hhf1j626e0d h6392fa6b6b45iidc5 9c7h7hhf1j626e0dh6392fa6b6b45iidc59c 7h7hhf1j626e0dh639 2fa6b6b45iidc59c7h 7hhf1j626e0dh6392fa6b6b45iidc59c7h7h hf1j626e0dh6392fa6 b6b45iidc59c7h7hhf 1j626e0dh6392fa~))
  • 39. “Most competitive” – spoiler• A “battle quine system” based on Elo rating• Main trick: Elo rating– A way of calculating the relative skill levels of players• Used in chess, shogi, etc.– Each program represents its own rate• Sub tricks: cheat OCR, abuse of -i$ ruby alice.rb bob.rb == alice.rb beats bob.rb$ ruby bob.rb ailce.rb == bob.rb beats alice.rb
  • 40. Top Four
  • 41. “Worst abuse of constants”mame leonid yhara eban shinh eto matz6 9 N/A 8 8 7 7Yutaka Hara (judge)Dishonorablemention7.5015:06:00 ← push 予定時刻
  • 42. “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 }...
  • 43. “Worst abuse of constants” –spoiler• Main Trick: pick up characters from constant names_ { return }  LocalJumpError_ { method(:p).unbind }  UnboundMethod_ { eval “{ “ }  SyntaxError_ { Thread.current.join }  ThreadError• Extra tricks– Another U is picked from RUBY_COPYRIGHT– JRuby fails to run this program
  • 44. “Most classic”mame leonid yhara eban shinh eto matzN/A 8 10 5 7 10 7Yusuke Endoh(judge)7.8315:09:30 ← push 予定時刻
  • 45. “Most classic”eval$C=%q(at_exit{open("/dev/dsp","wb"){|g|h=[0]*80$><<"¥s"*18+"eval$C=%q(#$C);S=%:"(S<<m=58).lines{|l|s=[128]*n=20E2t=0; h.map!{|v|d=?!==l[t]?1 :(l[t]== ?#)?0*v= 6:03(v<1 ?[]:0..n -1).each {|z|s[z] +=2*M.sin(($*[0] ||1).to_f*M.sin(y= 40*(z+m)*2**(t/12E0)/463)+ y)*(v-z*d/n)};t+=1;v-d};m+= n;g.flush<<(s.pack"C*"); puts(l)}}};M=Math);S=%:
  • 46. “Most classic” – spoiler• Main trick: music box with piano roll DSL– # is a note, and | is a slur• Extra tricks:– “eval-split-join” idiom is not used– Frequency modulation synthesisFM 音源合成• Judges’ comments– boring食傷気味
  • 47. “Most readable”mame leonid yhara eban shinh eto matz9 8 9 9 N/A 7 5Shinichiro Hamaji(judge)7.8315:13:00 ← push 予定時刻
  • 48. “Most readable”begin with an easy program.you should be able to writea program unless for you,program in ruby language istoo difficult. At the endof your journey towards theultimate program; you mustbe a part of a programminglanguage. You will end ifyou != program
  • 49. “Most readable” – spoiler• Main trick:– The whole structure is begin … end if false– for statement is used for defining variablesbegin...... unlessfor you, program in ......end...end if you != programbegin with an easy program.you should be able to writea program unless for you,program in ruby language istoo difficult. At the endof your journey towards theultimate program; you mustbe a part of a programminglanguage. You will end ifyou != program
  • 50. “Best pangram”mame leonid yhara eban shinh eto matz8 9 10 10 10 7 8kinaba8.8615:16:30 ← push 予定時刻
  • 51. “Best pangram”• The program prints each ASCII character from0x20 to 0x7e ~ exactly once.• The program contains each ASCII character from0x20 to 0x7e ~ exactly once.!@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz&[%r{¥"}mosx,4>6]|?while(putc 3_0-~$.+=9/2^5;)<18*7and:`#
  • 52. “Best pangram” – spoiler• Trick:– 32.upto(126) {|x| putc x }– But cannot “declare and then use” variables• Features– $. global variable, the best friend of Ruby golfers– Trash box of unused alphabets: THE QUICK BROWN …– Quote characters– Century puzzle-ish!@THEqQUICKbBROWNfFXjJMPSvVLAZYDGgkyz&[%r{¥"}mosx,4>6]|?while(putc 3_0-~$.+=9/2^5;)<18*7and:`#
  • 53. Judges’ comments• For winners業務連絡– Please come to the stage during the last demo最後の解説中に受賞者の方は前に集まってください
  • 54. Winning entries• "Good way to make programs wonderful“ – baban• “Most characteristic” – yoshi-taka• “Best way to return true” – unak• “Worst house of garbage” – Nakamura Narihiro• “Ruby by Ruby for Ruby award” – Yutaka Hara• “Most competitive” – Yusuke Endoh
  • 55. Dishonorable Top Four“Best pangram” – kinaba“Most Readable” – Shinichiro Hamaji“Most classic”– Yusuke Endoh“Worst abuse of constants” – Yutaka HaraDishonorablemention
  • 56. Prize?• Dishonor: the title of “insane”不名誉: 「変態」の称号• Top three entries will be included in the Ruby officialrepository as “sample” programs上位3作品はRuby公式リポジトリにコミットされます– The next Ruby tarball will be released with them次期 Ruby パッケージにも含まれた状態でリリースされます
  • 57. Conclusion• TRICK rules and winning entries:https://sites.google.com/site/trickcontest2013/• Future work– Next contest?– Please please submit your entry– Really looking forward to entries from foreign!