Cody

Problem 927. Knots Contest: Minimum Knots (TestSuite)

Solution 674488

Submitted on 24 May 2015 by Binbin Qi
  • Size: 12
  • This is the leading solution.
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 rehash path % Make numKnots.m available toc

ans = /users/mss.system.xK9qsU/Knots_sample.mat Elapsed time is 0.386792 seconds. ans = /users/mss.system.xK9qsU/numKnots.m Elapsed time is 0.662283 seconds.

3   Pass
%% cases=50; nKnots=zeros(cases,1); KnotTime=zeros(cases,1); load Knots_sample.mat testsuite=suite; % update 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) 10 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) 0 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) 0 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 10 msec Knot Score 373403.00 Cody Maximum allowed Elapsed time is approximately 53 seconds Elapsed time is 1.635916 seconds.

Suggested Problems

More from this Author246

Community Treasure Hunt

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

Start Hunting!