Cody

# Problem 43492. Create a square matrix with given conditions

Solution 1045107

Submitted on 5 Nov 2016 by JAEHYUK WOO
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))

y = 1 y = 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))

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

y = 1 2 3 4 5 y = 1 2 3 4 5 2 4 6 8 10 y = 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 y = 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 y = 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25 y = 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