Objective
Conway's game of life is a cellular automaton: each cell is alive or dead and its state in the next generation depends only on its eight neighbors.
Instructions
- The first line has
rows,columnsandg(number of generations). Then comerowslines with the board, where#is a live cell and.a dead one. - Rules: a live cell with 2 or 3 live neighbors stays alive; a dead one with exactly 3 live neighbors is born; in any other case it is dead. Outside the board everything is dead.
- Compute each generation from a copy, not from the board you are modifying. Show the final board.
5 5 2
.....
..#..
..#..
..#..
.....
.....
..#..
..#..
..#..
.....
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise