Jun-08-2019, 09:01 PM
Numpy arrays can be slice nicer then that.
table[0:3, 0:3]Quick way for game of life
import numpy size = 10, 10 table = numpy.random.randint(0, 2, size=size).astype(numpy.uint8) print(table) # neighbor count for x in range(size[0]): for y in range(size[1]): min_x = max(0, x - 1) max_x = min(size[0], x + 2) min_y = max(0, y - 1) max_y = min(size[1], y + 2) # Slicing the table slice_ = table[min_x:max_x, min_y:max_y] print(slice_, ' ', x, y, '\n') # Sum all minus self sum_ = numpy.sum(slice_) - table[x, y]
99 percent of computer problems exists between chair and keyboard.