Problem 52. What is the next step in Conway's Life?
Given a matrix A that represents the state of Conway's game of Life at one instant (time t=n), return the matrix B that represents the state of the game at the next instant (time t=n+1).
Assume a toroidal game board, so the edges of the matrix wrap left to right and top to bottom.
Examples:
Input A = [ 1 1 0 0
0 1 0 0
1 1 0 0
0 0 0 0 ]
Output B = [ 1 1 0 0
0 0 1 0
1 1 0 0
0 0 0 0 ]
Input A = [ 0 1 1 0
1 1 1 0
0 0 1 0
0 0 0 0 ]
Output B = [ 1 0 1 1
1 0 0 0
0 0 1 1
0 1 1 0 ]
Solution Stats
Problem Comments
-
11 Comments
Show
8 older comments
Dyuman Joshi
on 22 Aug 2023
Thanks for notifying @Peter, I have updated the link.
Jonah
on 9 Sep 2023
Am I misunderstanding the rules to the game, or are two of the solutions that the site checks against incorrect
Yufei
on 22 Jun 2024
I think the two of the solutions are wrong. Because it may misunderstand the corner...
Solution Comments
Show commentsProblem Recent Solvers655
Suggested Problems
-
Get the elements of diagonal and antidiagonal for any m-by-n matrix
484 Solvers
-
299 Solvers
-
376 Solvers
-
Who has power to do everything in this world?
452 Solvers
-
Relative ratio of "1" in binary number
1455 Solvers
More from this Author96
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!