Cody

Problem 698. Knots Contest: Score (TestSuite)

Solution 2525403

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
feval(@assignin,'caller','score',2000);

2   Fail
tic %urlwrite('http://tinyurl.com/matlab-Knots','Knots_sample.mat') %urlwrite('http://tinyurl.com/matlab-numKnots','numKnots.m') % Fast numKnots urlwrite('http://rmatlabtest.appspot.com/testsuite_sample_knots.mat','Knots_sample.mat') toc urlwrite('http://rmatlabtest.appspot.com/numKnots.m','numKnots.m') % Fast numKnots toc 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 5) urlwrite('http://rmatlabtest.appspot.com/testsuite_sample_knots.mat','Knots_sample.mat')

3   Fail
cases=50; % Reduced to 40 from 50 nKnots=zeros(cases,1); KnotTime=zeros(cases,1); load Knots_sample.mat testsuite=suite; 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)) T_score=6.5*exp(TKnotTime/23); Tknots=sum(nKnots);; fprintf('Time Score %10.2f\n',T_score) fprintf('Knot Score %10.2f\n',Tknots) fprintf('Total Score %10.2f\n',Tknots+T_score) fprintf('Cody Maximum allowed Elapsed time is approximately 53 seconds\n') toc feval( @assignin,'caller','score',min( 2000,Tknots+floor(T_score) ) );

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 Author241

Community Treasure Hunt

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

Start Hunting!