Cody

# Problem 1038. Change the sign of even index entries of the reversed vector

Solution 1860890

Submitted on 28 Jun 2019
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   Fail
x = [4 -5 -2 9]; y_correct = [9 2 -5 -4]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test1 (line 3) assert(isequal(your_fcn_name(x),y_correct))

2   Fail
x = ones(1,4); y_correct = [1 -1 1 -1]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test2 (line 3) assert(isequal(your_fcn_name(x),y_correct))

3   Fail
x = 1:10; y_correct = [10 -9 8 -7 6 -5 4 -3 2 -1]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test3 (line 3) assert(isequal(your_fcn_name(x),y_correct))

4   Fail
x = 2:2:12; y_correct = [12 -10 8 -6 4 -2]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test4 (line 3) assert(isequal(your_fcn_name(x),y_correct))

5   Fail
x = -3:3; y_correct = [3 -2 1 0 -1 2 -3]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test5 (line 3) assert(isequal(your_fcn_name(x),y_correct))

6   Fail
x = [1 1 2 3 5 8 13 21 34 55 89 144]; y_correct = [144 -89 55 -34 21 -13 8 -5 3 -2 1 -1]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test6 (line 3) assert(isequal(your_fcn_name(x),y_correct))

7   Fail
x = [1 0 1 0 1 0 1 0 1 0 1 0]; y_correct = [0 -1 0 -1 0 -1 0 -1 0 -1 0 -1]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test7 (line 3) assert(isequal(your_fcn_name(x),y_correct))

8   Fail
x = [0 1 0 2 0 3 0 4 0 5 0 6]; y_correct = [6 0 5 0 4 0 3 0 2 0 1 0]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test8 (line 3) assert(isequal(your_fcn_name(x),y_correct))

9   Fail
x = [0 1 0 1 0 1 0 1 0 1 0 1]; y_correct = [x(2:end) x(1)]; assert(isequal(your_fcn_name(x),y_correct))

Undefined function or variable 'n'. Error in your_fcn_name (line 2) y = flip(x).*((-1).^(n-1)); Error in Test9 (line 3) assert(isequal(your_fcn_name(x),y_correct))