Cody

# Problem 43651. create a square matrix

Solution 1209777

Submitted on 10 Jun 2017 by Said BOUREZG
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 = 3; y_correct =[1 4 9 4 4 9 9 9 9] assert(isequal(mat(n),y_correct))

y_correct = 1 4 9 4 4 9 9 9 9 ans = 1 0 0 0 0 0 0 0 0 ans = 1 4 0 0 0 0 0 0 0 ans = 1 4 0 4 0 0 0 0 0 ans = 1 4 0 4 4 0 0 0 0 ans = 1 4 9 4 4 0 0 0 0 ans = 1 4 9 4 4 9 0 0 0 ans = 1 4 9 4 4 9 9 0 0 ans = 1 4 9 4 4 9 9 9 0 ans = 1 4 9 4 4 9 9 9 9

2   Pass
n = 4; y_correct = [1 4 9 16 4 4 9 16 9 9 9 16 16 16 16 16] assert(isequal(mat(n),y_correct))

y_correct = 1 4 9 16 4 4 9 16 9 9 9 16 16 16 16 16 ans = 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 0 0 4 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 0 0 4 4 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 0 4 4 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 0 4 4 9 0 0 0 0 0 0 0 0 0 ans = 1 4 9 0 4 4 9 0 9 0 0 0 0 0 0 0 ans = 1 4 9 0 4 4 9 0 9 9 0 0 0 0 0 0 ans = 1 4 9 0 4 4 9 0 9 9 9 0 0 0 0 0 ans = 1 4 9 16 4 4 9 0 9 9 9 0 0 0 0 0 ans = 1 4 9 16 4 4 9 16 9 9 9 0 0 0 0 0 ans = 1 4 9 16 4 4 9 16 9 9 9 16 0 0 0 0 ans = 1 4 9 16 4 4 9 16 9 9 9 16 16 0 0 0 ans = 1 4 9 16 4 4 9 16 9 9 9 16 16 16 0 0 ans = 1 4 9 16 4 4 9 16 9 9 9 16 16 16 16 0 ans = 1 4 9 16 4 4 9 16 9 9 9 16 16 16 16 16

3   Pass
n= 7; y_correct =[1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 25 25 25 25 25 36 49 36 36 36 36 36 36 49 49 49 49 49 49 49 49] assert(isequal(mat(n),y_correct))

y_correct = 1 4 9 16 25 36 49 4 4 9 16 25 36 49 9 9 9 16 25 36 49 16 16 16 16 25 36 49 25 25 25 25 25 36 49 36 36 36 36 36 36 49 49 49 49 49 49 49 49 ans = 1 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 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 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 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 0 0 0 0 0 4 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 0 0 0 0 0 0 ans = 1 4 0 0 0 0 0 4 4 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 0 0 0 0 0 ans = 1 4 9 0 0 0 0 4 4 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 0 0 0 0 0 ans = 1 4 9 0 0 0 0 4 4 9 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 0 0 0 0 ans = 1 4 9 0 0 0 0 4 4 9 0 0 0 0 9 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 ans = 1 4 9 0 0 0 0 4 4 9 0 0 0 0 9 9 0 0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 0 16 16 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 0 0 4 4 9 16 25 0 0 9 9 9 16 25 0 0 16 16 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 0 0 4 4 9 16 25 0 0 9 9 9 16 25 0 0 16 16 16 16 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 0 0 4 4 9 16 25 0 0 9 9 9 16 25 0 0 16 16 16 16 25 0 0 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 0 0 4 4 9 16 25 0 0 9 9 9 16 25 0 0 16 16 16 16 25 0 0 25 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 0 0 4 4 9 16 25 0 0 9 9 9 16 25 0 0 16 16 16 16 25 0 0 25 25 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 0 0 4 4 9 16 25 0 0 9 9 9 16 25 0 0 16 16 16 16 25 0 0 25 25 25 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 0 0 4 4 9 16 25 0 0 9 9 9 16 25 0 0 16 16 16 16 25 0 0 25 25 25 25 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 36 0 4 4 9 16 25 0 0 9 9 9 16 25 0 0 16 16 16 16 25 0 0 25 25 25 25 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 36 0 4 4 9 16 25 36 0 9 9 9 16 25 0 0 16 16 16 16 25 0 0 25 25 25 25 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 36 0 4 4 9 16 25 36 0 9 9 9 16 25 36 0 16 16 16 16 25 0 0 25 25 25 25 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 36 0 4 4 9 16 25 36 0 9 9 9 16 25 36 0 16 16 16 16 25 36 0 25 25 25 25 25 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 36 0 4 4 9 16 25 36 0 9 9 9 16 25 36 0 16 16 16 16 25 36 0 25 25 25 25 25 36 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 36 0 4 4 9 16 25 36 0 9 9 9 16 25 36 0 16 16 16 16 25 36 0 25 25 25 25 25 36 0 36 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 1 4 9 16 25 36 0 4 4 9 16...