Hard
Game of Life
Read r rows of 0s and 1s and a number of steps. Run Conway's Game of Life that many steps (cells outside the grid are dead): a live cell with 2 or 3 live neighbours lives, a dead cell with exactly 3 becomes alive, all others die. Count neighbours by padding the grid with
np.pad and adding the 8 shifted slices. Print the final grid.Input
r, the rows (no spaces), then steps.
Output
r lines.
Sample 1
Input
5 00000 00100 00100 00100 00000 1
Output
00000 00000 01110 00000 00000
Sample 2
Input
3 000 010 000 1
Output
000 000 000
Output appears here