Cody

Solution 419039

Submitted on 16 Mar 2014 by Ahmad Alzahrani
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% x = rand(2,2,2); y = neg2(neg2(x)); y_correct = -x; assert(isequal(y,y_correct))

a = 2 2 2 y(:,:,1) = -0.8531 -0.9044 -0.4424 -0.0332 y(:,:,2) = -0.5324 -0.1793 -0.7165 -0.3365 a = 2 2 2 y(:,:,1) = -0.8531 -0.9044 -0.4424 -0.0332 y(:,:,2) = -0.5324 -0.1793 -0.7165 -0.3365

2   Pass
%% x = []; y = neg2(neg2(x)); y_correct = -x; assert(isequal(y,y_correct))

a = 0 0 a = 0 0

3   Pass
%% x = sqrt(-5); y = neg2(neg2(x)); y_correct = -x; assert(isequal(y,y_correct))

a = 1 1 a = 1 1

4   Pass
%% What does a single call give? x = rand; disp(neg2(x))

a = 1 1 -0.1877