Cody

# Problem 45269. Game of life - 01

Solution 2184251

Submitted on 31 Mar 2020 by Binbin Qi
• Size: 85
• This is the leading solution.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
n=1; A =[1 0 0 0;0 1 0 0;0 0 1 0;1 0 0 1]; y_correct = 1; assert(isequal(gameOfLife_3(A,n),y_correct))

2   Pass
n=10; A =[1 0 0 0;0 1 0 0;0 0 1 0;1 0 0 1]; y_correct = 1; assert(isequal(gameOfLife_3(A,n),y_correct))

3   Pass
n=5; A =[1 0 0 1;0 0 0 0;0 0 0 0;1 0 0 1]; y_correct =[1,2,3,4,5] ; assert(isequal(gameOfLife_3(A,n),y_correct))

4   Pass
n=10; A =[1 0 0 1;0 1 1 0;0 1 1 0;1 0 0 1]; assert(isempty(gameOfLife_3(A,n)))

5   Pass
n=10; A = [ ... 1 1 0 0 0 1 0 0 1 1 0 0 0 0 0 0]; y_correct = [1,3,4,5,7,8,9]; assert(isequal(gameOfLife_3(A,n),y_correct))

6   Pass
n=15; A = [ ... 0 1 1 0 1 1 1 0 0 0 1 0 0 0 0 0]; y_correct = 3; assert(isequal(gameOfLife_3(A,n),y_correct))

7   Pass
n=8; A =[0 0 0 0;0 0 0 1;0 0 0 1;0 1 1 1]; y_correct = 2; assert(isequal(gameOfLife_3(A,n),y_correct))

8   Pass
n=20; A =[0 0 0 0 0 0;1 0 0 1 0 0;0 0 0 1 0 0;0 1 0 0 0 1;1 0 1 0 1 0]; y_correct = 1; assert(isequal(gameOfLife_3(A,n),y_correct))

9   Pass
n=15; A=[0 0 0 0 0 0;1 0 0 1 0 0;0 0 0 1 0 0;0 1 0 0 0 1;1 0 1 0 1 0;0 0 0 1 1 1;0 1 0 0 0 0]; y_correct = 1; assert(isequal(gameOfLife_3(A,n),y_correct))