Created
December 3, 2011 09:00
-
-
Save dedan/1426608 to your computer and use it in GitHub Desktop.
ret
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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