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

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

                    
2
Pass
 
%%
% Functionality Tests
L=128;
a=randi(4,L,16,'uint8')-1;
b=randi(4,L,16,'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,16,'uint8')-1;
b=randi(4,L,16,'uint8')-1;
a(16:32,:)=b(32:48,:);
assert(isequal(ismember(a,b,'rows'),ismember_fast_rows(a,b)))

                    
3
Pass
 
%%
L=4000000;  % ismember 40    fast 5.2
% 34 sec 4M
tic
a=randi(4,L,16,'uint8')-1;
b=randi(4,L,16,'uint8')-1;
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(40000,t1); % ismember scores 40000 msec
feval(@assignin,'caller','score',floor(t2));
Elapsed time is 4.611042 seconds.
Elapsed time = 40598 msec