Cody

Problem 46663. Kaggle: Planetoid Game of Life - Variable Iterations for a wrapping array

Solution 3124786

Submitted on 8 Oct 2020 by Tim
• Size: 48
• 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
%Test Cases taken from Kaggle Training set %Case 4 iter=1; Astr='0001100000000000001000001000000000000001110010000100000000000000110001000100000000000000001001000000000000000000000010100000000000001000000000000000000000001010000000000000000000000001000000000000000000000001000000000110000000000000000000000100100000001100000000000001010000001001000000000000001000000110000000000000000000000000000000000000000000000000110000000000000000000000001000000000000000000011100000000000010000000000110000000000010100000000000000000000001010000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000100000000011000000000110110000000010010000000011110100010'; Bstr='0001100000000000001100011000000000000001010110001100000000000000000011000000000000000000011111100000000000000000000001000000000000001000000000000000000000000010000000000000000000000001000000000000000000000000000000000110000000000000000000000100100000001100000000000000011000001000000000000000010000000110000000000000000000000010100000000000000000000000110000000000000000000001011000000000000000000011100000000000010000000001010000000000010100000000010000000000001010000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000001100000000011000000000100001000000010010000000010000100000'; A=reshape(Astr-'0',25,25); B=reshape(Bstr-'0',25,25); C=iterlife(A,iter); if ~isequal(C,B) logical(A) logical(B) logical(C) end assert(isequal(C,B))

2   Pass
%Test Cases taken from Kaggle Training set %Case 16 iter=2; Astr='0011100100000000001111000101000010000000011010010000111101000000001000011011011100101100000110000100110000010100000000000111001000000100000100000110001100000000000100000001100000000000000101001111010011000000000011110010101010010000111101001100000110110001111111101100001011111000110110110001100001110000000000100111000011011000000011011000110000000100000001111100011000011100000001001000100000000010000001110100000001100100010001000010001100010000110000010000000000000011011100010000100000000000001011000000001000000000001101100000101000000000000100000000111101000000000000000000110000000000000000000011000100000000000010000'; Bstr='0000100000000000111101000000011000000000010011001110001101010000010010011010100100101100000110001100110000110010000000000001000100000110000000001011001100000000000110011000100000000000000101001100010111000000000000001010100011010000000000000011100000011000000000000111000000000000110000001111100000000000001000000100000011000000000110001100010000110100000010000111011100011010000010100111000001001000000011111100000000000001000001001110000000101110111100110000000000001101101000000000100000000000010000000001111000000000010001000001100000000000000101100001001110000000000001100001100000000000000000000000110110000000000011000'; A=reshape(Astr-'0',25,25); B=reshape(Bstr-'0',25,25); C=iterlife(A,iter); if ~isequal(C,B) logical(A) logical(B) logical(C) end assert(isequal(C,B))

3   Pass
%Test Cases taken from Kaggle Training set %Case 2 iter=3; Astr='0100000101000001000000110011000010000001100000000001000000110011000000000001000000011110000000010000100000000001110000000000000011000000101000000000001011110000010100000001000100100110001110000011001110011011000101100000101010000100000000000000000000000000000000000000101010000000000011101001011011110000000001111110110010001100000000001011101000010100000000000011000000010010000000010000111110000010000000010001000000000000000000001000001111000000000000000001010001000000000011000000001001000000000010100000000010100000000000100000000000000000001000000000000000101000001110000000000000100100001101111000000011000000001100000'; Bstr='1000001100100010001000101100000111000001000000001110000011100000000000000011000000011011011000000001101100001111111000000000110110110110100000000100011010000110100000000011000101010011011110000010010010000001000100000000010010001011100010001101000000000011000000001000110111000000000000000100000000101000000000000000000000000010000000000000010000100010000000000000100010001100000000010001111011000001000000010101100000100000000000001001011010100000000000000001010010010000000011000000011000000000000010100000000000000000110000100000000000000000101000000000000000000000010001000000000111000000010000011000000011100010001000000'; A=reshape(Astr-'0',25,25); B=reshape(Bstr-'0',25,25); C=iterlife(A,iter); if ~isequal(C,B) logical(A) logical(B) logical(C) end assert(isequal(C,B))

4   Pass
%Test Cases taken from Kaggle Training set %Case 1 iter=4; Astr='0000100001101010011100110000000000010000100101110000011000000110110001000000010010000010111000000010001000000000011100000001100100011100010110000000001100000111001010000001110000111100010111100000011111110100110000110001100010000100100100001000100001000110001110000000000101000000000001000000010111100000000111000000001000010000000011000000000000001100100000000000001110000011010100000000000000000011001001000000000000000000000011100000000000000000001100001111100000100000000000000110101001101100000001100000000110100110000010000000110010010000000001110000011111000111100000000000010100000000001000011000110000001100010111011'; Bstr='0000000000000000010000000000000000000110001110000001001100001001001111100100100110001100101100000000010000000111100000000001000000000000010000000000000001100000011100000010000000100000001110000001111101100000001110000000100001111000000010000000001001100010001101000000001101100001110000000001110011000000001111100000000000000000000011110000001100000001000000000000000000000010101010000000000000000011000111011011000010000001001011010111010010100000010100110100001010001000001110011000000100100100000011000011001110000110000010010000000001100001000010000000000011101010000000001100000001000000000000110000000011000000001000000'; A=reshape(Astr-'0',25,25); B=reshape(Bstr-'0',25,25); C=iterlife(A,iter); if ~isequal(C,B) logical(A) logical(B) logical(C) end assert(isequal(C,B))

5   Pass
%Test Cases taken from Kaggle Training set %Case 3 iter=5; Astr='0110000000000011000000011100000000000001100000001001100000000000100001011001001110000110000000010101000000001111100000101100000011011111100001011100000000101000000001100000001100011100000000100100001010000000000000010010000100000000000000000110000001000000000100000000001100000000000010001100000110000000010001000110000000000000011000100001000010000000011000011000100001000000000110000100010001010000000000001100000000001100000000000100000000001110000000000000000000000100100000001000000000000001010000011011000000000000110000001101100000000000000000000110110000000000000000000000100000000110000000001000000000000000000000000'; Bstr='1100001000000100000000011100001000000101000000001011110000000100000000001000000100000100000100000000000000000010001001000000000011111001010100100100010001100100000000000001001100011100000001010000001010000100000000000010000100000000000000010010000001000000001100000001000000000000111110001100001000000011011000001000101100000010000000000000001011000001001110010001001000100000110001100000011000010000001110000001000000011000000010000001000000010000000000000001000000011100000001000000000000000100110001000100010000000010001000000101001000000000100100100001000100000000001000001000000100000000000000010100000100000000000000010'; A=reshape(Astr-'0',25,25); B=reshape(Bstr-'0',25,25); C=iterlife(A,iter); if ~isequal(C,B) logical(A) logical(B) logical(C) end assert(isequal(C,B))

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!