Cody

# Problem 1976. Kaggle: Reverse Game of Life - Create Isle prior State

Solution 1710108

Submitted on 19 Jan 2019 by Binbin Qi
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
tic N=10; % size of Isle Qisles=100; % Qty of Isles to process to find error rate rng(15,'twister'); % creation fixed set of Isles valid=0; while valid<Qisles q=floor(N/4)+randi(floor(N*N/4)); idx=randperm(N*N); mb=zeros(N); mb(idx(1:q))=1; for i=1:10 % Pre-Evolve %mb0=mb; mc=conv2(single(mb),[1 1 1;1 0 1;1 1 1],'same'); mb=~(mc<2 | mc>3) & ((mb & mc==2) | (mb & mc==3) | (~mb & mc==3)); end if nnz(mb)>N*N/10 % Avoid empty isles % figure(1);imagesc(mb0) % figure(2);imagesc(mb) valid=valid+1; Isle{valid}=mb; end end % while to create cases errTot=0; for i=1:Qisles isle_predict=predict_prior_isle(Isle{i}); m1=isle_predict; % Evolve to calculate errors mc=conv2(single(m1),[1 1 1;1 0 1;1 1 1],'same'); isle_created=~(mc<2 | mc>3) & ((m1 & mc==2) | (m1 & mc==3) | (~m1 & mc==3)); err=N*N-nnz(Isle{i}==isle_created); errTot=errTot+err; end % Qisles toc assignin('caller','score',min(200,floor(1000*errTot/N/N/Qisles)));

Elapsed time is 0.053994 seconds.

### Community Treasure Hunt

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

Start Hunting!