

Conway's Game of Life in 140 bytes Ruby - netmute
https://gist.github.com/1761463

======
tomstuart
Off the top of my head, some simple ways to make this shorter:

    
    
      * Use 0...s*s instead of 0..s*s-1
      * Use 0..s*s instead of 0...s*s (overrunning g doesn't matter much)
      * Use count{|x|x} instead of compact.count
      * Get rid of ||nil (because count{|x|x} ignores all falsy values)
      * Get rid of the brackets around g[i]&&n==2
      * Use [g[i-s-1,3],g[i-1],g[i+1],g[i+s-1,3]].flatten instead of [[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]]
      * Use -1..s*s instead of 0..s*s and substitute i+1 for i (i.e. g[i+1] instead of g[i], but [g[i-s,3],g[i],g[i+2],g[i+s,3]] instead of [g[i-s-1,3],g[i-1],g[i+1],g[i+s-1,3]])

~~~
elitheeli
I really should have refreshed the comments page before shortening... seems
like we think similarly: <https://gist.github.com/1803557>

------
eddie_the_head
And in APL:

life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }

------
peteretep
And in 131 characters of Perl: <https://gist.github.com/1803656>

What do I win?

~~~
peteretep
Actually, what I /really/ won was the happy feeling I got from abusing $a and
$b even though it runs under strict.

------
Cushman
It's all ASCII... If you're using octets for each character, you can
definitely still squeeze a few bytes out of that.

------
samwilliams
Those interested in this post may like the examples on this page:
[http://codegolf.stackexchange.com/questions/3434/shortest-
ga...](http://codegolf.stackexchange.com/questions/3434/shortest-game-of-life)

------
raganwald
See also: <http://willbailey.name/conway/docs/conway.html>

------
namidark
None of these examples ran with 1.9.3 :\

~~~
netmute
OP here. I'm pretty sure they run in 1.9.3 because I wrote them in it.

