Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Life Counter solution in Uncategorized category for Life Counter by capback250
COORDS = ((-1, -1), (-1, 0), (-1, 1),
( 0, -1), ( 0, 1),
( 1, -1), ( 1, 0), ( 1, 1))
def life_counter(cors, steps, i = 0):
alive = [[id1, id2] for id1, key1 in enumerate(cors) for id2, key2 in enumerate(key1) if key2]
while i < steps:
will_born, will_live = [], []
for point in alive:
for neibor in [[point[0] + c[0], point[1] + c[1]] for c in COORDS]:
if sum([alive.count([neibor[0] + c[0], neibor[1] + c[1]]) for c in COORDS]) == 3 and neibor not in alive+will_born:
will_born.append(neibor)
if sum([alive.count([point[0] + c[0], point[1] + c[1]]) for c in COORDS]) in [2,3]:
will_live.append(point)
i += 1
alive = will_born+will_live
return len(alive)
Jan. 13, 2016