AdvancedChallenge 27 of 34

Conway's Game of Life

Write step(grid) that returns the next generation of a Game of Life grid (a of of 0/1). A live cell with two or three live neighbours survives; a dead cell with exactly three comes alive; everything else dies. Cells outside the grid count as dead.

Examples
A blinker [[0,1,0],[0,1,0],[0,1,0]] becomes [[0,0,0],[1,1,1],[0,0,0]]
Exercise

Conway's Game of Life

4 checks
def step(grid):
    ...


for row in step([[0, 1, 0], [0, 1, 0], [0, 1, 0]]):
    print("".join("█" if c else "·" for c in row))
 
Python (loads on first run)Ctrl+Enter runs
Output
Press Run to try your code, then Check answer to grade it.