Skip to content

Instantly share code, notes, and snippets.

@garybernhardt
Created December 6, 2009 16:17
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 garybernhardt/250285 to your computer and use it in GitHub Desktop.
Save garybernhardt/250285 to your computer and use it in GitHub Desktop.
def live_cell_count(x, y):
square_coords = [(x-1, y-1),
(x+0, y-1),
(x+1, y-1),
(x-1, y+0),
(x+1, y+0),
(x-1, y+1),
(x+0, y+1),
(x+1, y+1)]
count = sum(1 for x, y in square_coords
if cell_alive_exists(x, y))
return count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment