This question already has an answer here:
- Shortest Game of Life 30 answers
Given an array of strings representing a grid of cells
With the key :
0 = 'dead cell'
1 = 'live cell'
write a function that returns the next iteration following the rules of Conway's Game of Life .
- Any live cell with fewer than two live neighbours dies, as if caused by underpopulation.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overpopulation.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
["111" , "110" , "100"] //input ["101" , "001" , "110"] // output /** * There will be other tests so no hardcoding. **/
This is code golf shortest code wins. Good luck and have fun