Cody

# Problem 1975. Kaggle: Reverse Game of Life - Zoo of Stills and Oscillators

Solution 2650565

Submitted on 4 Jul 2020 by Rafael S.T. Vieira
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
block=[0 0 0 0;0 1 1 0;0 1 1 0;0 0 0 0]; Zoo=repmat(block,3,1); ZooPre=Zoo_prior(Zoo); mc=conv2(single(ZooPre),[1 1 1;1 0 1;1 1 1],'same'); ZooChk=~(mc<2 | mc>3) & ((ZooPre & mc==2) | (ZooPre & mc==3) | (~ZooPre & mc==3)); assert(all(all(ZooChk==Zoo))) % figure(1);imagesc(ZooPre) % figure(2);imagesc(Zoo)

2   Pass
caterer1=[0 0 0 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 0;0 1 0 0 0 1 1 1 1 0;0 1 0 0 0 1 0 0 0 0;0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0;0 0 1 1 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0]; caterer2=[0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 1 1 0 0; 0 0 1 0 1 1 1 1 0 0; 1 1 1 0 0 1 0 1 0 0; 0 0 0 0 0 0 0 0 0 0; 0 0 1 1 0 0 0 0 0 0; 0 0 0 1 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0]; caterer3=[0 0 0 0 0 0 0 0 0 0; 0 0 0 0 0 0 0 1 0 0; 0 0 1 1 1 0 0 0 1 0; 0 1 1 1 1 1 0 1 0 0; 0 0 0 1 0 0 0 0 0 0; 0 0 1 1 0 0 0 0 0 0; 0 0 1 1 0 0 0 0 0 0; 0 0 0 0 0 0 0 0 0 0]; Zoo=[caterer1 zeros(8,1) caterer2 zeros(8,1) caterer3] ; ZooPre=Zoo_prior(Zoo); mc=conv2(single(ZooPre),[1 1 1;1 0 1;1 1 1],'same'); ZooChk=~(mc<2 | mc>3) & ((ZooPre & mc==2) | (ZooPre & mc==3) | (~ZooPre & mc==3)); assert(all(all(ZooChk==Zoo))) % figure(1);imagesc(ZooPre) % figure(2);imagesc(Zoo)

3   Pass
caterer1=[0 0 0 0 0 0 0 0 0 0;0 0 0 1 0 0 0 0 0 0;0 1 0 0 0 1 1 1 1 0;0 1 0 0 0 1 0 0 0 0;0 1 0 0 0 0 0 0 0 0;0 0 0 0 1 0 0 0 0 0;0 0 1 1 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0 0]; % 8x10 Loaf=[0 0 0 0 0 0;0 0 1 1 0 0;0 1 0 0 1 0;0 0 1 0 1 0;0 0 0 1 0 0;0 0 0 0 0 0]; % 6x6 blinker=[0 0 0 0 0;0 0 0 0 0;0 1 1 1 0;0 0 0 0 0;0 0 0 0 0]; % 5x5 Zoo=[[Loaf;Loaf'] zeros(12,1) [caterer1;zeros(4,10)] [blinker;blinker';zeros(2,5)] ] ; ZooPre=Zoo_prior(Zoo); mc=conv2(single(ZooPre),[1 1 1;1 0 1;1 1 1],'same'); ZooChk=~(mc<2 | mc>3) & ((ZooPre & mc==2) | (ZooPre & mc==3) | (~ZooPre & mc==3)); assert(all(all(ZooChk==Zoo))) % figure(1);imagesc(ZooPre) % figure(2);imagesc(Zoo)