Cody

# Problem 43492. Create a square matrix with given conditions

Solution 1043963

Submitted on 4 Nov 2016 by Binbin Qi
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
n = 1; y_correct = 1; assert(isequal(ResultMatrix(n),y_correct))

ans = 1

2   Pass
n = 10; y_correct = [100 90 80 70 60 50 40 30 20 10; 90 81 72 63 54 45 36 27 18 9; 80 72 64 56 48 40 32 24 16 8; 70 63 56 49 42 35 28 21 14 7; 60 54 48 42 36 30 24 18 12 6; 50 45 40 35 30 25 20 15 10 5; 40 36 32 28 24 20 16 12 8 4; 30 27 24 21 18 15 12 9 6 3; 20 18 16 14 12 10 8 6 4 2; 10 9 8 7 6 5 4 3 2 1]; assert(isequal(ResultMatrix(n),y_correct))

ans = 100 90 80 70 60 50 40 30 20 10 90 81 72 63 54 45 36 27 18 9 80 72 64 56 48 40 32 24 16 8 70 63 56 49 42 35 28 21 14 7 60 54 48 42 36 30 24 18 12 6 50 45 40 35 30 25 20 15 10 5 40 36 32 28 24 20 16 12 8 4 30 27 24 21 18 15 12 9 6 3 20 18 16 14 12 10 8 6 4 2 10 9 8 7 6 5 4 3 2 1

3   Pass
n = 5; y_correct = [25 20 15 10 5; 20 16 12 8 4; 15 12 9 6 3; 10 8 6 4 2; 5 4 3 2 1]; assert(isequal(ResultMatrix(n),y_correct))

ans = 25 20 15 10 5 20 16 12 8 4 15 12 9 6 3 10 8 6 4 2 5 4 3 2 1