MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Solution 141546

Submitted on 24 Sep 2012 by Richard Zapor

Correct

6988Size
`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

```%%
% Warm-Up Calls and functionality check
tic
c=randi(4,1024,48,'uint8')-1;
out = unique_rows_fast(c);
assert(isequal(unique(c,'rows'),out))
c=randi(4,2048,48,'uint8')-1;
out = unique_rows_fast(c);
assert(isequal(unique(c,'rows'),out))
c=randi(4,4096,48,'uint8')-1;
out = unique_rows_fast(c);
assert(isequal(unique(c,'rows'),out))
toc
```
```Elapsed time is 0.112152 seconds.
```
3
Pass

```%%
tic
c=randi(4,4000000,48,'uint8')-1;
toc
ta=clock;
out = unique_rows_fast(c);
t1=etime(clock,ta)*1000;
tic
assert(isequal(unique(c,'rows'),out)) %
toc
t2=min(20000,t1); % unique scores 18.1 sec
fprintf('Actual Time = %.0f msec\n',t1)
feval(@assignin,'caller','score',floor(t2));
```
```Elapsed time is 6.851218 seconds.
Elapsed time is 16.694297 seconds.
Actual Time = 6989 msec
```