Cody

Problem 46706. Kaggle: Planetoid Game of Life - Total Score 0.10

Solution 3101316

Submitted on 7 Oct 2020 by Richard Zapor
  • Size: 19
  • 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
%'https://sites.google.com/site/razapor/matlab_cody/mtest.mat?attredirects=0&d=1'; %mtest format is [casenumer, iterations, start1:625,finish1:625] for 50K cases 0:49999 %'https://sites.google.com/site/razapor/matlab_cody/mtrain.mat?attredirects=0&d=1'; fname='https://sites.google.com/site/razapor/matlab_cody/mtest.mat?attredirects=0&d=1'; urlwrite(fname,'mtest.mat') %1.22s load('mtest.mat'); %0.42s cerr=zeros(50000,1); for i=1:50000 cerr(i)=nnz(mtest(i,3:end)); end tic mstart = solveLife(mtest); toc mstart=unique(mstart,'rows'); % remove exact duplicate solutions %Calc errors for each case submitted, otherwise use 0 input errors tic for i=1:size(mstart,1) % icase=mstart(i,1); %50000:99999 Abase=reshape(mtest(icase-49999,3:end),25,25);; iter=mtest(icase-49999,2); %Test cases start at 50000 A=reshape(mstart(i,2:end),25,25); for j=1:iter C=0; for r=-1:1 % -1 Up Using circshift to perform wrap convolution Ar=circshift(A,r,1); for c=-1:1 % -1 Left Arc=circshift(Ar,c,2); C=C+Arc; end end A = C==3 | A&C==4; end %j cerr(icase-49999)=nnz(Abase-A); end %main loop i toc % 4.5s Score=sum(cerr)/50000/625; fprintf('Score %.4f Total Errors: %i\n',Score,sum(cerr)); assert(Score<=0.10)

ans = '/users/mss.system.RqV6CA/mtest.mat' fname = 'https://sites.google.com/site/razapor/matlab_cody/Life8_m.mat?attredirects=0&d=1' ans = '/users/mss.system.RqV6CA/Life8_m.mat' Elapsed time is 1.080463 seconds. Elapsed time is 4.539255 seconds. Score 0.0818 Total Errors: 2556293

Suggested Problems

More from this Author246

Community Treasure Hunt

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

Start Hunting!