aboutsummaryrefslogtreecommitdiffstats
path: root/sample/trick2015/eregon/entry.rb
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-11 14:37:06 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-11 14:37:06 +0000
commit5c28308f9fbb44bfc73fe8af58fdcce0ad0379f2 (patch)
treeb096f65a2e92c00028406ba988cd5e55094ab2f4 /sample/trick2015/eregon/entry.rb
parentd65bc80d3f71bf5423a6a6d9b3f8d4ff2faf6bd5 (diff)
downloadruby-5c28308f9fbb44bfc73fe8af58fdcce0ad0379f2.tar.gz
* sample/trick2015/: added the award-winning entries of TRICK 2015.
See https://github.com/tric/trick2015 for the contest outline. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'sample/trick2015/eregon/entry.rb')
-rw-r--r--sample/trick2015/eregon/entry.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/sample/trick2015/eregon/entry.rb b/sample/trick2015/eregon/entry.rb
new file mode 100644
index 0000000000..b325c6c198
--- /dev/null
+++ b/sample/trick2015/eregon/entry.rb
@@ -0,0 +1,16 @@
+class String;def[]*a;$*<<a;b;end;end;
+_=0;z="C=Fiber;s=$*;a=*0..8;l=C.new{e
+xit},*a.product(a).select{|r,c|s[r][c
+]==0}."[1,9,_, _,_,8, _,_,5]+"map{|r,
+c|C.ne"[_,_,2, _,5,_, _,8,9]+"w{o=s[r
+][c];l"[8,_,6, 7,4,_, _,_,_]+"oop{(1.
+.9).map{|n|C.yield(s[r][c]=n)if a.non
+e?{|k|"[_,_,_, _,_,4, _,9,2]+"s[r][k]
+==n||s"[_,2,3, _,7,_, 8,1,_]+"[k][c]=
+=n||s["[5,6,_, 8,_,_, _,_,_]+"r-r%3+k
+%3][c-c%3+k/3]==n}};s[r][c]=o;C.yield
+}}},C."[_,_,_, _,2,7, 9,_,3]+"new{loo
+p{puts"[9,3,_, _,8,_, 1,_,_]+" s.map{
+|r|r*'"[2,_,_, 5,_,_, _,4,8]+" '}<<''
+;C.yield}};c=l[i=1];loop{c=l[i+=c.res
+ume ? 1:-1]}";eval z.tr ?\n,'' \ No newline at end of file