Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
%%
x = rand(10000, 1);
z = rand(10000, 1);
x = vertcat(x, z);
tic
y_correct = unique(x);
t_unique = toc
tic
y_myunique = my_unique(x);
t_myunique = toc
assert(isequal(sort(my_unique(x)),y_correct) && t_unique > t_myunique)
t_unique =
0.0386
Elapsed time is 0.000776 seconds.
t_myunique =
2.2000e-05
Elapsed time is 0.000288 seconds.
|
2 | Pass |
%%
x = rand(50000, 1);
z = rand(50000, 1);
x = vertcat(x, z);
tic
y_correct = unique(x);
t_unique = toc
tic
y_my_unique = my_unique(x);
t_my_unique = toc
assert(isequal(sort(my_unique(x)),y_correct) && t_unique > t_my_unique)
t_unique =
0.0206
Elapsed time is 0.000026 seconds.
t_my_unique =
1.5000e-05
Elapsed time is 0.000064 seconds.
|
3 | Pass |
%%
x = [1; 2; 3; 4; 2; 3; 4; 5;];
tic
y_correct = unique(x);
t_unique = toc
tic
y_my_unique = my_unique(x);
t_my_unique = toc
assert(isequal(sort(my_unique(x)),y_correct) && t_unique > t_my_unique)
t_unique =
1.9600e-04
Elapsed time is 0.000037 seconds.
t_my_unique =
1.2000e-05
Elapsed time is 0.000050 seconds.
|
9839 Solvers
74 Solvers
Project Euler: Problem 1, Multiples of 3 and 5
1492 Solvers
Create matrix of replicated elements
321 Solvers
111 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!