Yay, 10 msec! Any way to compare solutions by timing performance?
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
feval(@assignin,'caller','score',0);
|
2 | Pass |
L=1000;
a=randi(2^32-1,L*1.2,1,'uint32');
a=unique(a,'R2012a');
a=a(1:L);
% Warm-Up Test cases
for i=1:5:1000
assert(isequal(find_fast(a,a(i)),i))
end
|
3 | Pass |
% Timing Performance Case
L=12000000;
a=randi(2^32-1,L*1.2,1,'uint32');
a=unique(a,'R2012a');
a=a(1:L);
q=200;
val=zeros(q,1);
for i=1:q
val(i)=a(randi(L));
end
t0=clock;
for i=1:q
ptr=find_fast(a,val(i));
end
dt=etime(clock,t0)*1000;
assert(isequal(find_fast(a,val(1)),find(a==val(1),1,'first')))
fprintf('Your Time = %i msec\n',floor(dt))
feval(@assignin,'caller','score',min(200,floor(dt)));
% Performance Score
Your Time = 10 msec
|
316 Solvers
Create a square matrix of multiples
383 Solvers
Set the array elements whose value is 13 to 0
935 Solvers
How many monitors are connected ?
127 Solvers
228 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!