Skip to content

Instantly share code, notes, and snippets.

@kunjee17
Created September 6, 2013 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kunjee17/6461208 to your computer and use it in GitHub Desktop.
Save kunjee17/6461208 to your computer and use it in GitHub Desktop.
Game of life in Ruby
life=->g,s{(0..s*s-1).map{|i|->n{n==3||(g[i]&&n==2)||nil}
[[g[i-s-1],g[i-s],g[i-s+1],g[i-1],g[i+1],g[i+s-1],g[i+s],g[i+s+1]]
.compact.count]}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment