Posted By

gdonald on 09/27/06

Tagged

Viewed 0 times

ruby ascii golf example


/ Published in: Ruby


  1. #!/usr/bin/env ruby
  2.  
  3. $><<"\e[2J";s,o,f,c,u=20,"#"," ";b,m=(z=0..s).map{z.map{(rand<0.3)?o:f}},[-1,0,1]*3;until c==b;c=b.map{|z|z.dup};$><<"\e[H"<<b.map{|x|x*f}*"";s.times{|i|s.times{|e|n=(m.sort.zip(m)-[[0,0]]).select{|x,z|o==(c[i+x]||[])[e+z]}.size;n!=2?b[i][e]=n==3?o:f:f}};sleep 0.2;end

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.