Cody

Problem 939. DNA Pattern Match: Performance Metric - Speed

Solution 615478

Submitted on 10 Apr 2015
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   Fail
%% feval(@assignin,'caller','score',0);

Error: You may not use the command(s) builtin in your code

2   Fail
%% % Functionality Section Pass=1; w=6; DNA=randi(4,1,1800000,'uint8')-1; Patterns=randi(4,12,6,'uint8')-1; % Create more than needed Patterns=unique(Patterns,'rows','stable'); % Elim dupes but maintain random Patterns=Patterns(1:6,:); % Take first 6 random vectors Patterns=unique(Patterns,'rows'); % Place in order for easier debugging DNA_ID=1; Locations = find_DNA(DNA, DNA_ID, Patterns); if isempty(Locations),Pass=0;end if max(size(Locations))<1024,Pass=0;end for i=1:size(Locations,1) Pass=Pass && ismember(DNA(Locations(i,end):Locations(i,end)+w-1),Patterns,'rows'); end DNA=randi(4,1,1800000,'uint8')-1; Patterns=randi(4,24,6,'uint8')-1; % Create more than needed Patterns=unique(Patterns,'rows','stable'); % Elim dupes but maintain random Patterns=Patterns(1:12,:); % Take first 6 random vectors Patterns=unique(Patterns,'rows'); % Place in order for easier debugging DNA_ID=2; Locations = find_DNA(DNA, DNA_ID, Patterns); if isempty(Locations),Pass=0;end if max(size(Locations))<1024,Pass=0;end for i=1:size(Locations,1) Pass=Pass && ismember(DNA(Locations(i,end):Locations(i,end)+w-1),Patterns,'rows'); end assert(isequal(Pass,1))

Error: You may not use the command(s) builtin in your code

3   Fail
%% % Timing Section DNA=randi(4,1,1800000,'uint8')-1; Patterns=randi(4,12,6,'uint8')-1; % Create more than needed Patterns=unique(Patterns,'rows','stable'); % Elim dupes but maintain random Patterns=Patterns(1:6,:); % Take first 6 random vectors Patterns=unique(Patterns,'rows'); % Place in order for easier debugging DNA_ID=1; Locations = find_DNA(DNA, DNA_ID, Patterns); Locations = find_DNA(DNA, DNA_ID, Patterns); t0=clock; for i=1:10 Locations = find_DNA(DNA, DNA_ID, Patterns); end dt1=etime(clock,t0)*1000; % msec conversion fprintf('Your Set 1 Time = %i msec\n',floor(dt1)) Patterns=randi(4,24,6,'uint8')-1; % Create more than needed Patterns=unique(Patterns,'rows','stable'); % Elim dupes but maintain random Patterns=Patterns(1:12,:); % Take first 12 random vectors Patterns=unique(Patterns,'rows'); % Place in order for easier debugging t0=clock; for i=1:10 Locations = find_DNA(DNA, DNA_ID, Patterns); end dt2=etime(clock,t0)*1000; % msec conversion fprintf('Your Set 2 Time = %i msec\n',floor(dt2)) % New DNA Set DNA=randi(4,1,1800000,'uint8')-1; Patterns=randi(4,12,6,'uint8')-1; % Create more than needed Patterns=unique(Patterns,'rows','stable'); % Elim dupes but maintain random Patterns=Patterns(1:6,:); % Take first 6 random vectors Patterns=unique(Patterns,'rows'); % Place in order for easier debugging DNA_ID=2; Locations = find_DNA(DNA, DNA_ID, Patterns); Locations = find_DNA(DNA, DNA_ID, Patterns); t0=clock; for i=1:10 Locations = find_DNA(DNA, DNA_ID, Patterns); end dt3=etime(clock,t0)*1000; % msec conversion fprintf('Your Set 3 Time = %i msec\n',floor(dt3)) feval(@assignin,'caller','score',min(400,floor(double(dt1+dt2+dt3)/30)));

Error: You may not use the command(s) builtin in your code

Suggested Problems

More from this Author241

Community Treasure Hunt

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

Start Hunting!