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
-
Project Euler: Problem 1, Multiples of 3 and 5
3380 Solvers
-
530 Solvers
-
340 Solvers
-
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1724 Solvers
-
Convert from Fahrenheit to Celsius
24941 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!