Cody

# Problem 44080. Construct a "diagAdiag" matrix

Solution 1710137

Submitted on 19 Jan 2019 by HH
• Size: 9
• This is the leading solution.
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 = 3; y_correct = [1 2 6; 3 5 7;4 8 9]; assert(isequal(diagAdiag(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In diagAdiag (line 2) In ScoringEngineTestPoint1 (line 3) In solutionTest (line 3)]

2   Pass
x = 4; y_correct = [1 2 6 7; 3 5 8 13;4 9 12 14;10 11 15 16]; assert(isequal(diagAdiag(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In diagAdiag (line 2) In ScoringEngineTestPoint2 (line 3) In solutionTest (line 5)]

3   Pass
x = 5; y_correct = [1 2 6 7 15;3 5 8 14 16;4 9 13 17 22;10 12 18 21 23;11 19 20 24 25]; assert(isequal(diagAdiag(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In diagAdiag (line 2) In ScoringEngineTestPoint3 (line 3) In solutionTest (line 7)]

4   Pass
x = 6; y_correct = [ 1 2 6 7 15 16; 3 5 8 14 17 26; 4 9 13 18 25 27; 10 12 19 24 28 33; 11 20 23 29 32 34; 21 22 30 31 35 36]; assert(isequal(diagAdiag(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In diagAdiag (line 2) In ScoringEngineTestPoint4 (line 8) In solutionTest (line 9)]

5   Pass
x = 7; y_correct = [ 1 2 6 7 15 16 28; 3 5 8 14 17 27 29; 4 9 13 18 26 30 39; 10 12 19 25 31 38 40; 11 20 24 32 37 41 46; 21 23 33 36 42 45 47; 22 34 35 43 44 48 49]; assert(isequal(diagAdiag(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In diagAdiag (line 2) In ScoringEngineTestPoint5 (line 9) In solutionTest (line 11)]