Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
9-liner: sometimes complex means simplest solution in Clear category for Life Counter by przemyslaw.daniel
def life_counter(state, tick_n):
from collections import Counter
rh, rw = range(len(state)), range(len(state[0]))
live = {x+y*1j for x in rh for y in rw if state[x][y]}
neighbor = 1, -1, 1j, -1j, 1-1j, -1+1j, 1+1j, -1-1j
for _ in range(tick_n):
count = Counter(x+y for x in neighbor for y in live)
live = {x for x in count if 3-(x in live) <= count[x] <= 3}
return len(live)
Jan. 7, 2018
Comments: