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

20000Size
Leading solution size is 2162.
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',20000);

                    
2
Pass
 
%%
% Functionality Tests
L=128;
a=randi(4,L,48,'uint8')-1;
b=randi(4,L,48,'uint8')-1;
assert(isequal(ismember(a,b,'rows'),ismember_fast_rows(a,b)))
b=a;
assert(isequal(ismember(a,b,'rows'),ismember_fast_rows(a,b)))
L=256;
a=randi(4,L,48,'uint8')-1;
b=randi(4,L,48,'uint8')-1;
a(16:32,:)=b(32:48,:);
assert(isequal(ismember(a,b,'rows'),ismember_fast_rows(a,b)))

                    
3
Pass
 
%%
% 2M has a crash for 2x ismember
L=1900000;  % ismember 19.6    fast  C 8.3 2M
tic
a=randi(4,L,48,'uint8')-1;
b=randi(4,L,48,'uint8')-1;
a(100:200,:)=b(400:500,:); % Put in some matching data
toc
ta=clock;
idx = ismember_fast_rows(a,b);
t1=etime(clock,ta)*1000;
fprintf('Elapsed time = %.0f msec\n',t1)
assert(isequal(ismember(a,b,'rows'),idx))
t2=min(20000,t1); % ismember 1.9M x 48 scores 19000 msec
feval(@assignin,'caller','score',floor(t2));
Elapsed time is 6.984023 seconds.
Elapsed time = 22587 msec