Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 320511

Submitted on 18 Sep 2013 by Alfonso Nieto-Castanon

Correct

100Size
Leading solution size is 6.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
feval(@assignin,'caller','score',100);

                    
2
Pass
 
%%
tic
urlwrite('http://rmatlabtest.appspot.com/testsuite_GeneSeq_contest.mat','testsuite_GeneSeq_contest.mat')
toc
ans =
/users/msssystem18/testsuite_GeneSeq_contest.mat
Elapsed time is 0.449409 seconds.
3
Pass
 
%%
load testsuite_GeneSeq_contest
cases=size(testsuite,2);
Result=zeros(cases,3);
 for i=1:27 % Practice runs
 segments=testsuite{i};
 solution = geneseq(segments);
 end % i cases
 for i=1:29 %1:29 %cases
    segments=testsuite{i};
    OriginalGene=one_answer{i};
    t0 = cputime;
     solution = geneseq(segments); % 99.998065  51667.47  0.452
    time_elapsed = cputime-t0;
   % Check = checksequence(segments,solution);
     Check=1;
     for ichk = 1:size(segments,1)
      if isempty(findstr(segments(ichk,:),solution))
       Check=0;
       break
      end
     end
    if Check == 1
        Result(i,1) = length(solution);
        Result(i,2) = time_elapsed;
        Result(i,3) = length(OriginalGene);
    else
        Result(i,:) = Inf;
    end
 end % i cases
 fprintf('Net Time=%10.6f\n',sum(Result(:,2)))
 fprintf('Result= %10.6f\n',100*sum(Result(:,1))/sum(Result(:,3)))
 v=1000*(sum(Result(:,1)./Result(:,3))/size(Result,1)-1)+ sum(Result(:,2))*10;
 fprintf('Final Score %.2f\n',v)
 fprintf('L %5i Time %7.3f  L_orig %5i\n',Result')
 assert(max(Result(:,1))< Inf)
 feval( @assignin,'caller','score',floor(min( 100,v )) );
Net Time= 18.460000
Result= 113.231281
Final Score 1743.24
L   122 Time   0.050  L_orig    65
L   117 Time   0.070  L_orig    65
L   202 Time   0.120  L_orig    65
L   129 Time   0.050  L_orig   100
L   189 Time   0.080  L_orig   100
L   206 Time   0.120  L_orig   100
L   185 Time   0.060  L_orig    65
L    65 Time   0.050  L_orig    65
L   964 Time   0.260  L_orig    65
L   100 Time   0.020  L_orig   100
L   286 Time   0.100  L_orig   100
L   162 Time   0.110  L_orig   100
L   367 Time   0.080  L_orig   100
L   370 Time   0.110  L_orig   100
L   278 Time   0.130  L_orig   100
L   202 Time   0.110  L_orig    67
L   146 Time   0.090  L_orig    97
L    64 Time   0.050  L_orig    37
L   349 Time   0.180  L_orig    37
L    93 Time   0.080  L_orig    67
L   178 Time   0.060  L_orig    97
L   468 Time   0.230  L_orig   400
L   282 Time   0.120  L_orig   200
L   100 Time   0.060  L_orig   100
L    10 Time   0.000  L_orig    10
L    26 Time   0.010  L_orig    26
L  6384 Time   2.710  L_orig  5000
L 23010 Time   6.650  L_orig 20789
L 23456 Time   6.700  L_orig 23456