This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.
17 Apr 2015: 2L. Time used = 3.099 seconds in last test case.
Test | Status | Code Input and Output |
---|---|---|
1 | Pass |
x = [ 0 1 ; 2 3 ] ;
y_correct = [ -0.5 0.5 ; -0.5 0.5 ] ;
y = remove_average_vectorized(x);
assert(isequal(y,y_correct));
|
2 | Pass |
%%
x = [ 0 1 ; 2 3 ] ;
timer=tic;
y = remove_average_vectorized(x);
duration=toc(timer)
% You can probably pass this test with a for loop.
assert(duration<0.1,sprintf('Time used %2.3f\n',duration));
duration =
1.4500e-04
|
3 | Pass |
%%
x = [ 1:9999 ; 2:10000 ; [ zeros(1,9998) 9999 ] ];
x = repmat(x,1000,1);
y_correct = [ -4999:1:4999 ; -4999:1:4999 ; [ repmat(-1,1,9998) 9998 ] ];
y_correct = repmat(y_correct,1000,1);
y = remove_average_vectorized(x);
assert(isequal(y,y_correct));
|
4 | Fail |
%%
x = [ 1:9999 ; 2:10000 ; [ zeros(1,9998) 9999 ] ];
x = repmat(x,1000,1);
timer=tic;
y = remove_average_vectorized(x);
duration=toc(timer)
% A decent vectorized solution should take around 1 second.
assert(duration<2,sprintf('Time used %2.3f\n',duration));
Error: Time used 3.099
|
Replace NaNs with the number that appears to its left in the row.
1712 Solvers
553 Solvers
Find the sum of the elements in the "second" diagonal
880 Solvers
690 Solvers
374 Solvers