On 5/3/06, Joey <rubytalk / eachmapinject.com> wrote: > Asking for a bit of help, I have the following code at > http://www.eachmapinject.com/code/game_of_life_golf.rb which is an > implemintation of the Game of Life > I would like to be able to have it as a signature, you know 80*4, but its 34 > characters over. > Any suggestions on golfing/shortening it anymore? I've taken it down by 15 (to 347 not including newlines) trivially: * -7: inline values of L and s * -3: add a var, N, which is nil, and replace all () with u * -3: remove redundant ,() from initialization sequence (a,b,c=1,2; c #=> nil) * -2: replace " " with f on line 2 * 0: uppercase constants O and F O,F,N,c="#"," ";b=([N]*20).map{(0..20).map{(rand<0.3)?O:F}};$><<"\e[2J";until c==b;$><<"\e[H"<<b.map{|x|x*F}*"\n";c=b.map{|z|z.dup};b.each_index{|i|b[i].each_index{ |e|n=(q,z=-1..1,[];q.map{|x|q.map{|y|z<<[x,y]}};(z-=[[0,0]]).map{|x|c[i+x[0]][e+x[1]]rescue N}-[F,N]).size;(b[i][e]==O)?(n>3||n<2)?b[i][e]=F:N:(n==3)?b[i][e]=O:N}};sleep 0.2;end Cheers, Dave