Gamified challenge · Neighbour counting
cells is a lab dish: 1 is a live cell and 0 an empty spot. Each spot has up to 8 neighbours (up, down, left, right and the 4 diagonals); spots beyond the edge count as empty.
Every spot changes at the same moment, based only on the current dish: a live cell with 2 or 3 live neighbours survives, any other live cell dies; an empty spot with exactly 3 live neighbours becomes live, otherwise it stays empty.
Write nextGen(cells) that returns the dish one generation later (same shape). Example: the vertical bar [[0,1,0],[0,1,0],[0,1,0]] becomes the horizontal bar [[0,0,0],[1,1,1],[0,0,0]]. An empty dish [] stays [].
This game is part of the paid plans. Sign in, then pick a plan to write your answer, watch it play out, and step through the algorithm with its guide.
Sign in with Google