Skip to content

Instantly share code, notes, and snippets.

@dedan
Created December 3, 2011 09:00
Show Gist options
  • Save dedan/1426608 to your computer and use it in GitHub Desktop.
Save dedan/1426608 to your computer and use it in GitHub Desktop.
ret
import numpy as np
import pylab as plt
import time
living_cells = set([(1, 0), (1, 1), (1, 2)])
counting = {}
neighbors = [(-1, -1), (0, -1), (1, -1),
(-1, 0), (1, 0),
(-1, 1), (0, 1), (1, 1)]
for x, y in living_cells:
for m, n in neighbors:
tmp = (x+m, y+n)
if not tmp in counting:
counting[tmp] = 0
print tmp
if tmp in living_cells:
counting[tmp] += 1
print 'added'
print counting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment