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

Solution 173946

Submitted on 6 Dec 2012 by James

Correct

2000Size
Leading solution size is 966.
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',0);

                    
2
Pass
 
%%
x8=randi(255,1000000,5,'uint8');
x16=randi(2^16,1000000,4,'uint16');
x32=randi(2^32,3000000,1,'uint32');
for i=1:5 % Warmup Calls to get valid timing
 x8w=unique_fast(x8);
end
ta=clock;
%tic
 x8u=unique_fast(x8);
%toc
%tic
 x16u=unique_fast(x16);
%toc
%tic
 x32u=unique_fast(x32);
%toc
t1=etime(clock,ta)*1000;
assert(isequal(x8u,unique(x8)))
assert(isequal(x16u,unique(x16)))
assert(isequal(x32u,unique(x32)))
t2=min(2000,t1); % unique scores 2000 msec
feval(@assignin,'caller','score',floor(t2));