Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
One liner version n Conway's Game of Life
s=30;Array.new((s+2)*(s+2),0).tap{|g|(s*s).times{|i|[100,133,163,164,165].each{|i|g[i]=1}};100.times{s.times{|y|puts s.times.map{|x|g[x+s+3+y*(s+2)]==1??*:?.}.join};(s*s).times.map{|i|i+=i/s*2;[0,1,2,3,5,6,7,8].map{|x|g[i+x%3+x/3*2+x/3*s]}.sum.yield_self{|x|x==3?1:x==2?g[i+s+3]:0}}.tap{|n|(s*s).times{|i|g[i+s+3+i/s*2]=n[i]}};sleep(0.1);print"\e[#{s}A"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment