Cody

Solution 1885984

Submitted on 28 Jul 2019 by hao
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 = [1 2 3 4 5 5 6 5 7 9 8 3]; y_correct = [0 0 0 4 0 0 6 0 0 9 0 0]; assert(isequal(your_fcn_name(x),y_correct))

y = (3,2) 9 (2,3) 6 (1,4) 4

2   Pass
x = magic(4); y_correct = [16 0 0 0 0 11 0 0 0 0 0 12 0 0 15 0]; assert(isequal(your_fcn_name(x),y_correct))

y = (1,1) 16 (2,2) 11 (4,3) 15 (3,4) 12

3   Pass
x = pi; y_correct = pi; assert(isequal(your_fcn_name(x),y_correct))

y = (1,1) 3.1416

4   Pass
x = 0; y_correct = 0; assert(isequal(your_fcn_name(x),y_correct))

y = All zero sparse: 1×1

5   Pass
x = toeplitz(1:5); y_correct = [ 0 0 0 0 5 0 0 0 0 4 3 0 0 0 0 4 0 0 0 0 5 0 0 0 0]; assert(isequal(your_fcn_name(x),y_correct))

y = (3,1) 3 (4,1) 4 (5,1) 5 (1,5) 5 (2,5) 4

6   Pass
x = ones(5); y_correct = [ 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0]; assert(isequal(your_fcn_name(x),y_correct))

y = (1,1) 1 (2,1) 1 (3,1) 1 (4,1) 1 (5,1) 1

7   Pass
x =nchoosek(7:9,3); y_correct =[ 0 0 9]; assert(isequal(your_fcn_name(x),y_correct))

y = (1,3) 9

8   Pass
x =nchoosek(4:9,2); y_correct = [ 0 5 0 6 0 7 0 8 0 9 0 6 0 7 0 8 0 9 0 7 0 8 0 9 0 8 0 9 0 9]; assert(isequal(your_fcn_name(x),y_correct))

y = (1,2) 5 (2,2) 6 (3,2) 7 (4,2) 8 (5,2) 9 (6,2) 6 (7,2) 7 (8,2) 8 (9,2) 9 (10,2) 7 (11,2) 8 (12,2) 9 (13,2) 8 (14,2) 9 (15,2) 9