Cody

# Problem 698. Knots Contest: Score (TestSuite)

Solution 161485

Submitted on 13 Nov 2012 by Aurelien Queffurust
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/msssystem5/Knots_sample.mat Elapsed time is 0.269006 seconds. ans = /users/msssystem5/numKnots.m Elapsed time is 0.360207 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.372160 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) 389 Knots 1 2 KnotTime(msec) 110 Knots 5 3 KnotTime(msec) 199 Knots 5 4 KnotTime(msec) 1280 Knots 13 5 KnotTime(msec) 50 Knots 6 6 KnotTime(msec) 250 Knots 15 7 KnotTime(msec) 680 Knots 7 8 KnotTime(msec) 100 Knots 5 9 KnotTime(msec) 110 Knots 23 10 KnotTime(msec) 949 Knots 6 11 KnotTime(msec) 400 Knots 18 12 KnotTime(msec) 2360 Knots 67 13 KnotTime(msec) 50 Knots 1 14 KnotTime(msec) 899 Knots 43 15 KnotTime(msec) 230 Knots 44 16 KnotTime(msec) 1639 Knots 100 17 KnotTime(msec) 449 Knots 25 18 KnotTime(msec) 400 Knots 38 19 KnotTime(msec) 1020 Knots 7 20 KnotTime(msec) 110 Knots 6 21 KnotTime(msec) 129 Knots 13 22 KnotTime(msec) 1860 Knots 51 23 KnotTime(msec) 460 Knots 55 24 KnotTime(msec) 170 Knots 34 25 KnotTime(msec) 40 Knots 0 26 KnotTime(msec) 120 Knots 7 27 KnotTime(msec) 110 Knots 15 28 KnotTime(msec) 149 Knots 14 29 KnotTime(msec) 140 Knots 14 30 KnotTime(msec) 259 Knots 35 31 KnotTime(msec) 199 Knots 30 32 KnotTime(msec) 1020 Knots 105 33 KnotTime(msec) 1280 Knots 57 34 KnotTime(msec) 470 Knots 8 35 KnotTime(msec) 2000 Knots 64 36 KnotTime(msec) 79 Knots 11 37 KnotTime(msec) 370 Knots 57 38 KnotTime(msec) 259 Knots 10 39 KnotTime(msec) 100 Knots 13 40 KnotTime(msec) 1529 Knots 40 41 KnotTime(msec) 90 Knots 0 42 KnotTime(msec) 1240 Knots 8 43 KnotTime(msec) 200 Knots 19 44 KnotTime(msec) 1469 Knots 22 45 KnotTime(msec) 110 Knots 14 46 KnotTime(msec) 500 Knots 16 47 KnotTime(msec) 99 Knots 7 48 KnotTime(msec) 80 Knots 6 49 KnotTime(msec) 259 Knots 20 50 KnotTime(msec) 60 Knots 5 Sum KnotTime 26540 msec Time Score 20.61 Knot Score 1185.00 Total Score 1205.61 Cody Maximum allowed Elapsed time is approximately 53 seconds Elapsed time is 28.896817 seconds. ```