Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
scipy.ndimage solution in 3rd party category for Life Counter by gyahun_dash
from scipy import pad
from scipy.ndimage import convolve
def life_counter(state, ticks):
for t in range(ticks):
padded = pad(state, 1, 'constant', constant_values=0)
convolved = convolve(padded, weights=[[1, 1, 1], [1, 0, 1], [1, 1, 1]])
state = (padded & (convolved == 2)) | (convolved == 3)
return int(state.sum())
Jan. 22, 2017
Comments: