function gene = test(a0)
[n,L] = size(a0);
[sums is] = sort( a0 * rand(L,1) ) ;
a0 = a0( is(diff([sums ; 0]) ~= 0), :);
nii = size(a0,1) ;
a = cell(nii,1);
for k = 1:nii,
a{k} = a0(k,:);
end;
gTail = 2-L:0;
for N = L-1:-1:1,
i1 = 1;
while i1<=nii,
while 1,
cPart = find(strncmp(a{i1}(end+gTail),a, N));
if cPart,
mSeg = cPart(1);
if mSeg~=i1,
a{i1} = [a{i1} a{mSeg}(1+N:end)];
nii=nii-1;
if nii == 1,
gene = a{i1};
return;
end;
if mSeg<i1, i1=i1-1; end;
a(mSeg) = [];
else
break;
end;
else
break;
end;
end;
i1=i1+1;
end;
gTail(1) = [];
end;
gene = [a{:}];
|