Cody

Problem 46686. Kaggle: Planetoid Game of Life - Solve 3000 of 50000 Puzzles

Solution 3124546

Submitted on 8 Oct 2020 by Tim
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'; tic 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 toc numtosolve=3000; mstart = solveLife(mtest,numtosolve); toc mstart=unique(mstart,'rows'); % remove exact duplicate solutions valid=0; for i=1:size(mstart,1) % <0.5sec to process 3K cases icase=mstart(i,1); %50000:99999 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 if isequal(A(:)',mtest(icase-49999,3:end)) % mtest [case, iter, data1:625] valid=valid+1; else valid=0; break; end end %main loop i toc assert(valid>=3000)

ans = '/users/mss.system.HXCNUM/mtest.mat' Elapsed time is 1.411536 seconds. Elapsed time is 13.360050 seconds. Elapsed time is 13.831575 seconds.

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!