Problem 927. Knots Contest: Minimum Knots (TestSuite)

Solution 2525415

Submitted on 12 Jun 2020
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

2   Fail
tic %urlwrite('','Knots_sample.mat') %urlwrite('','numKnots.m') % Fast numKnots urlwrite('','Knots_sample.mat') toc urlwrite('','numKnots.m') % Fast numKnots rehash path % Make numKnots.m available toc

Error using urlreadwrite (line 98) Error downloading URL. Your network connection may be down or your proxy settings improperly configured. Error in urlwrite (line 52) [f,status] = urlreadwrite(mfilename,catchErrors,url,filename,varargin{:}); Error in Test2 (line 4) urlwrite('','Knots_sample.mat')

3   Fail
cases=50; nKnots=zeros(cases,1); KnotTime=zeros(cases,1); load Knots_sample.mat testsuite=suite; % update for n=1:cases a=testsuite(n).a; xyIn=testsuite(n).xyIn; wts=testsuite(n).wts; rng(2,'twister') time0 = cputime; xyOut=solver(a,xyIn,wts); KnotTime(n) = cputime - time0; if size(unique(xyOut,'rows'),1)<length(wts) nKnots(n)=Inf; % Points must be unique else nKnots(n)=numKnots(xyOut,a); end end for n=1:cases fprintf('%2i KnotTime(msec) %5i Knots %4i\n',n,floor(KnotTime(n)*1000),nKnots(n)) end TKnotTime=sum(KnotTime); fprintf('Sum KnotTime %5i msec\n',floor(TKnotTime*1000)) Tknots=sum(nKnots);; fprintf('Knot Score %10.2f\n',Tknots) fprintf('Cody Maximum allowed Elapsed time is approximately 53 seconds\n') toc feval( @assignin,'caller','score',min( 2000,Tknots ) );

Error using load Unable to read file 'Knots_sample.mat'. No such file or directory. Error in Test3 (line 5) load Knots_sample.mat

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!