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

Correct

254Size
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
Code Input and Output
1
Pass
 
tic
L=4176; % 1040  Special Selection for W=48 and 16 overlap
Gtruth=randi(4,1,L,'uint8')-1;
segs=zeros(floor(L/32),48);
for i=0:size(segs,1)-1  % Ideal Overlap segment creator
 segs(i+1,:)=Gtruth(i*32+1:i*32+48);
end
v=randperm(size(segs,1));
segs(:,:)=segs(v,:);
% Flip random segments
f=logical(randi(2,size(segs,1),1)-1);
segs(f,:)=fliplr(segs(f,:));
Gout = Genome_001(segs);
toc
assert(isequal(Gout,Gtruth)||isequal(Gout,fliplr(Gtruth)))
Elapsed time is 1.820350 seconds.
2
Pass
 
%%
tic
L=1040; % Special Selection for W=48 and 16 overlap
Gtruth=randi(4,1,L,'uint8')-1;
segs=zeros(floor(L/32),48);
for i=0:size(segs,1)-1  % Ideal Overlap segment creator
 segs(i+1,:)=Gtruth(i*32+1:i*32+48);
end
v=randperm(size(segs,1));
segs(:,:)=segs(v,:);
f=logical(randi(2,size(segs,1),1)-1);
segs(f,:)=fliplr(segs(f,:));
Gout = Genome_001(segs);
toc
assert(isequal(Gout,Gtruth)||isequal(Gout,fliplr(Gtruth)))
Elapsed time is 0.099406 seconds.