Build the neighbour count array for grid — the sum of all eight shifted copies

NumPy · from Capstone: Conway’s Game of Life, without a single loop

np.rollboolean masksastypeshifted sumswrap-aroundsimulation

Putting the kettle on…

Starting up…

Exercise 2

Build the neighbour count array for grid — the sum of all eight shifted copies. Same shape as grid.

your answer
stuck? the lesson behind it
Capstone: Conway’s Game of Life, without a single loop
A whole simulation in two lines of array arithmetic.