Cody

Solution 1710136

Submitted on 19 Jan 2019 by HH
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))

ans = 0 0 0 2 0 0 1 3 0 ans = 6 0 0 2 5 0 1 3 4 ans = 6 7 0 2 5 8 1 3 4 ans = 6 7 9 2 5 8 1 3 4 ans = 1 2 6 3 5 7 4 8 9

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))

ans = 0 0 0 0 0 0 0 0 2 0 0 0 1 3 0 0 ans = 0 0 0 0 6 0 0 0 2 5 0 0 1 3 4 0 ans = 7 0 0 0 6 8 0 0 2 5 9 0 1 3 4 10 ans = 7 13 0 0 6 8 12 0 2 5 9 11 1 3 4 10 ans = 7 13 14 0 6 8 12 15 2 5 9 11 1 3 4 10 ans = 7 13 14 16 6 8 12 15 2 5 9 11 1 3 4 10 ans = 1 2 6 7 3 5 8 13 4 9 12 14 10 11 15 16

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))

ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 1 3 0 0 0 ans = 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 2 5 0 0 0 1 3 4 0 0 ans = 0 0 0 0 0 7 0 0 0 0 6 8 0 0 0 2 5 9 0 0 1 3 4 10 0 ans = 15 0 0 0 0 7 14 0 0 0 6 8 13 0 0 2 5 9 12 0 1 3 4 10 11 ans = 15 16 0 0 0 7 14 17 0 0 6 8 13 18 0 2 5 9 12 19 1 3 4 10 11 ans = 15 16 22 0 0 7 14 17 21 0 6 8 13 18 20 2 5 9 12 19 1 3 4 10 11 ans = 15 16 22 23 0 7 14 17 21 24 6 8 13 18 20 2 5 9 12 19 1 3 4 10 11 ans = 15 16 22 23 25 7 14 17 21 24 6 8 13 18 20 2 5 9 12 19 1 3 4 10 11 ans = 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

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))

ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 1 3 0 0 0 0 ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 2 5 0 0 0 0 1 3 4 0 0 0 ans = 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 6 8 0 0 0 0 2 5 9 0 0 0 1 3 4 10 0 0 ans = 0 0 0 0 0 0 15 0 0 0 0 0 7 14 0 0 0 0 6 8 13 0 0 0 2 5 9 12 0 0 1 3 4 10 11 0 ans = 16 0 0 0 0 0 15 17 0 0 0 0 7 14 18 0 0 0 6 8 13 19 0 0 2 5 9 12 20 0 1 3 4 10 11 21 ans = 16 26 0 0 0 0 15 17 25 0 0 0 7 14 18 24 0 0 6 8 13 19 23 0 2 5 9 12 20 22 1 3 4 10 11 21 ans = 16 26 27 0 0 0 15 17 25 28 0 0 7 14 18 24 29 0 6 8 13 19 23 30 2 5 9 12 20 22 1 3 4 10 11 21 ans = 16 26 27 33 0 0 15 17 25 28 32 0 7 14 18 24 29 31 6 8 13 19 23 30 2 5 9 12 20 22 1 3 4 10 11 21 ans = 16 26 27 33 34 0 15 17 25 28 32 35 7 14 18 24 29 31 6 8 13 19 23 30 2 5 9 12 20 22 1 3 4 10 11 21 ans = 16 26 27 33 34 36 15 17 25 28 32 35 7 14 18 24 29 31 6 8 13 19 23 30 2 5 9 12 20 22 1 3 4 10 11 21 ans = 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

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))

ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 1 3 0 0 0 0 0 ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 2 5 0 0 0 0 0 1 3 4 0 0 0 0 ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 7 0 0 0 0 0 0 6 8 0 0 0 0 0 2 5 9 0 0 0 0 1 3 4 10 0 0 0 ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 0 0 0 0 0 0 7 14 0 0 0 0 0 6 8 13 0 0 0 0 2 5 9 12 0 0 0 1 3 4 10 11 0 0 ans = 0 0 0 0 0 0 0 16 0 0 0 0 0 0 15 17 0 0 0 0 0 7 14 18 0 0 0 0 6 8 13 19 0 0 0 2 5 9 12 20 0 0 1 3 4 10 11 21 0 ans = 28 0 0 0 0 0 0 16 27 0 0 0 0 0 15 17 26 0 0 0 0 7 14 18 25 0 0 0 6 8 13 19 24 0 0 2 5 9 12 20 23 0 1 3 4 10 11 21 22 ans = 28 29 0 0 0 0 0 16 27 30 0 0 0 0 15 17 26 31 0 0 0 7 14 18 25 32 0 0 6 8 13 19 24 33 0 2 5 9 12 20 23 34 1 3 4 10 11 21 22 ans = 28 29 39 0 0 0 0 16 27 30 38 0 0 0 15 17 26 31 37 0 0 7 14 18 25 32 36 0 6 8 13 19 24 33 35 2 5 9 12 20 23 34 1 3 4 10 11 21 22 ans = 28 29 39 40 0 0 0 16 27 30 38 41 0 0 15 17 26 31 37 42 0 7 14 18 25 32 36 43 6 8 13 19 24 33 35 2 5 9 12 20 23 34 1 3 4 10 11 21 22 ans = 28 29 39 40 46 0 0 16 27 30 38 41 45 0 15 17 26 31 37 42 44 7 14 18 25 32 36 43 6 8 13 19 24 33 35 2 5 9 12 20 23 34 1 3 4 10 11 21 22 ans = 28 29 39 40 46 47 0 16 27 30 38 41 45 48 15 17 26 31 37 42 44 7 14 18 25 32 36 43 6 8 13 19 24 33 35 2 5 9 12 20 23 34 1 3 4 10 11 21 22 ans = 28 29 39 40 46 47 49 16 27 30 38 41 45 48 15 17 26 31 37 42 44 7 14 18 25 32 36 43 6 8 13 19 24 33 35 2 5 9 12 20 23 34 1 3 4 10 11 21 22 ans = 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

Suggested Problems