Cody

# Problem 1136. Knots Contest: Score (ContestSuite)

Solution 2525424

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-KnotsContest','Knots_contest.mat') %urlwrite('http://tinyurl.com/matlab-numKnots','numKnots.m') % Fast numKnots urlwrite('http://rmatlabtest.appspot.com/testsuite_Contest_knots.mat','Knots_contest.mat') toc urlwrite('http://rmatlabtest.appspot.com/numKnots.m','numKnots.m') % Fast numKnots rehash path % Make numKnots.m available toc

3   Fail
cases=50; nKnots=zeros(cases,1); KnotTime=zeros(cases,1); load Knots_contest.mat 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_contest.mat'. No such file or directory. Error in Test3 (line 5) load Knots_contest.mat

### Community Treasure Hunt

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

Start Hunting!