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
-
Replace NaNs with the number that appears to its left in the row.
3012 Solvers
-
Back to basics 12 - Input Arguments
605 Solvers
-
Circular Primes (based on Project Euler, problem 35)
569 Solvers
-
745 Solvers
-
Check that number is whole number
4557 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!