Problem statement
Given a grid of live and dead cells, produce the next generation from the eight neighbours of every cell.
A live cell survives on two or three live neighbours, a dead cell is born on exactly three, and every other cell becomes dead.
Examples
Input[[0, 0, 0], [1, 1, 1], [0, 0, 0]]
Output[[0, 1, 0], [0, 1, 0], [0, 1, 0]]
The horizontal line of three becomes a vertical line, because each live cell has exactly two live neighbours.
Input[[1, 0, 0], [0, 0, 0], [0, 0, 0]]
Output[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
A lone corner cell has no live neighbours, so it dies and nothing is born.
The walkthrough is part of Premium
The statement and the examples above stay free. The full how-to-solve walkthrough, the cost notes in plain words and the interactive step-by-step visualizer unlock with a Premium plan.
See pricing