Cody

Solution 172774

Submitted on 5 Dec 2012 by @bmtran
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

This solution is outdated. To rescore this solution, log in.

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 rehash path % Make numKnots.m available toc
ans = /users/msssystem9/Knots_sample.mat ans = /users/msssystem9/numKnots.m [Warning: Function /opt/mlsedu/mdcsserver/latest/m/web_common/shadow/license.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/home.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/keyboard.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/more.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] [Warning: Function /opt/mlsedu/mdcsserver/latest/m/common/shadow/pause.m has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In verifyCode>evaluateCode at 226 In verifyCode at 40 In fevalJSON at 14] Elapsed time is 3.948356 seconds.
3   Pass
%% cases=50; nKnots=zeros(cases,1); KnotTime=zeros(cases,1); load Knots_sample.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)) 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 ) );
1 KnotTime(msec) 620 Knots 1 2 KnotTime(msec) 110 Knots 2 3 KnotTime(msec) 190 Knots 0 4 KnotTime(msec) 1059 Knots 18 5 KnotTime(msec) 39 Knots 6 6 KnotTime(msec) 300 Knots 17 7 KnotTime(msec) 500 Knots 7 8 KnotTime(msec) 120 Knots 4 9 KnotTime(msec) 170 Knots 20 10 KnotTime(msec) 539 Knots 6 11 KnotTime(msec) 439 Knots 20 12 KnotTime(msec) 2490 Knots 67 13 KnotTime(msec) 40 Knots 0 14 KnotTime(msec) 929 Knots 43 15 KnotTime(msec) 349 Knots 44 16 KnotTime(msec) 2290 Knots 102 17 KnotTime(msec) 539 Knots 25 18 KnotTime(msec) 500 Knots 36 19 KnotTime(msec) 610 Knots 2 20 KnotTime(msec) 129 Knots 6 21 KnotTime(msec) 159 Knots 9 22 KnotTime(msec) 2860 Knots 53 23 KnotTime(msec) 840 Knots 76 24 KnotTime(msec) 240 Knots 36 25 KnotTime(msec) 30 Knots 0 26 KnotTime(msec) 139 Knots 7 27 KnotTime(msec) 139 Knots 10 28 KnotTime(msec) 210 Knots 15 29 KnotTime(msec) 220 Knots 16 30 KnotTime(msec) 389 Knots 28 31 KnotTime(msec) 289 Knots 31 32 KnotTime(msec) 2009 Knots 91 33 KnotTime(msec) 2240 Knots 61 34 KnotTime(msec) 469 Knots 8 35 KnotTime(msec) 3169 Knots 71 36 KnotTime(msec) 110 Knots 4 37 KnotTime(msec) 580 Knots 68 38 KnotTime(msec) 259 Knots 9 39 KnotTime(msec) 100 Knots 11 40 KnotTime(msec) 1799 Knots 37 41 KnotTime(msec) 80 Knots 0 42 KnotTime(msec) 1299 Knots 8 43 KnotTime(msec) 310 Knots 17 44 KnotTime(msec) 1210 Knots 22 45 KnotTime(msec) 120 Knots 11 46 KnotTime(msec) 420 Knots 10 47 KnotTime(msec) 129 Knots 5 48 KnotTime(msec) 100 Knots 3 49 KnotTime(msec) 330 Knots 20 50 KnotTime(msec) 79 Knots 4 Sum KnotTime 32310 msec Knot Score 1167.00 Cody Maximum allowed Elapsed time is approximately 53 seconds Elapsed time is 38.675514 seconds.