5
Description :
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 .
Rules
- 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.
Examples :
["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
Comments are not for extended discussion; this conversation has been moved to chat.
– Mego – 2018-04-12T22:40:18.777