Cody

# Problem 698. Knots Contest: Score (TestSuite)

Solution 160367

Submitted on 10 Nov 2012 by Richard Zapor
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   Pass
%% 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
``` ans = /users/msssystem19/Knots_sample.mat Elapsed time is 0.231104 seconds. ans = /users/msssystem19/numKnots.m Elapsed time is 0.862092 seconds. [Warning: Function license has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14] [Warning: Function mex has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14] [Warning: Function home has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14] [Warning: Function keyboard has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14] [Warning: Function more has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14] [Warning: Function pause has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14] [Warning: Function simulink has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 231 In verifyCode at 40 In fevalJSON at 14] Elapsed time is 0.875258 seconds. ```
3   Pass
%% 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) ) );
``` 1 KnotTime(msec) 0 Knots 94 2 KnotTime(msec) 0 Knots 50 3 KnotTime(msec) 0 Knots 1719 4 KnotTime(msec) 0 Knots 11390 5 KnotTime(msec) 0 Knots 18 6 KnotTime(msec) 0 Knots 3446 7 KnotTime(msec) 0 Knots 7402 8 KnotTime(msec) 0 Knots 669 9 KnotTime(msec) 0 Knots 2558 10 KnotTime(msec) 0 Knots 13557 11 KnotTime(msec) 0 Knots 5376 12 KnotTime(msec) 0 Knots 25025 13 KnotTime(msec) 0 Knots 122 14 KnotTime(msec) 0 Knots 11566 15 KnotTime(msec) 9 Knots 2560 16 KnotTime(msec) 0 Knots 15726 17 KnotTime(msec) 0 Knots 7569 18 KnotTime(msec) 0 Knots 11728 19 KnotTime(msec) 0 Knots 35178 20 KnotTime(msec) 0 Knots 1872 21 KnotTime(msec) 0 Knots 972 22 KnotTime(msec) 0 Knots 29917 23 KnotTime(msec) 0 Knots 7433 24 KnotTime(msec) 0 Knots 2013 25 KnotTime(msec) 0 Knots 3 26 KnotTime(msec) 0 Knots 3081 27 KnotTime(msec) 0 Knots 1381 28 KnotTime(msec) 0 Knots 1424 29 KnotTime(msec) 0 Knots 1102 30 KnotTime(msec) 0 Knots 3534 31 KnotTime(msec) 0 Knots 2849 32 KnotTime(msec) 0 Knots 14520 33 KnotTime(msec) 0 Knots 16892 34 KnotTime(msec) 0 Knots 16553 35 KnotTime(msec) 0 Knots 18887 36 KnotTime(msec) 0 Knots 245 37 KnotTime(msec) 0 Knots 5729 38 KnotTime(msec) 0 Knots 3256 39 KnotTime(msec) 0 Knots 400 40 KnotTime(msec) 0 Knots 24811 41 KnotTime(msec) 9 Knots 290 42 KnotTime(msec) 0 Knots 15081 43 KnotTime(msec) 0 Knots 5679 44 KnotTime(msec) 0 Knots 12310 45 KnotTime(msec) 0 Knots 262 46 KnotTime(msec) 0 Knots 16317 47 KnotTime(msec) 0 Knots 1614 48 KnotTime(msec) 0 Knots 249 49 KnotTime(msec) 0 Knots 8782 50 KnotTime(msec) 0 Knots 192 Sum KnotTime 19 msec Time Score 6.51 Knot Score 373403.00 Total Score 373409.51 Cody Maximum allowed Elapsed time is approximately 53 seconds Elapsed time is 3.177936 seconds. ```