Cody

# Problem 364. Matrix spiral

Solution 1219952

Submitted on 26 Jun 2017 by Augusto Mazzei
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 =[0]; assert(isequal(Matrix_Spiral(n),y_correct))

or = 1 0 0 -1 -1 0 0 1

2   Pass
n = 2; y_correct =[11 11 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

or = 1 0 0 -1 -1 0 0 1

3   Pass
n = 3; y_correct =[11 11 11 0 0 11 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

or = 1 0 0 -1 -1 0 0 1 k = 1 x = 2 y = 3

4   Pass
n = 4; y_correct =[11 11 11 11 0 0 0 11 0 0 11 11 0 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

or = 1 0 0 -1 -1 0 0 1 k = 1 x = 2 y = 4 x = 3 y = 4 k = 2 x = 3 y = 3

5   Pass
n = 5; y_correct =[11 11 11 11 11 0 0 0 0 11 0 0 11 0 11 0 0 11 11 11 0 0 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

or = 1 0 0 -1 -1 0 0 1 k = 1 x = 2 y = 5 x = 3 y = 5 x = 4 y = 5 k = 2 x = 4 y = 4 x = 4 y = 3 k = 3 x = 3 y = 3

6   Pass
n = 10; y_correct =[11 11 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 11 0 0 11 11 11 11 11 11 0 11 0 0 11 0 0 0 0 11 0 11 0 0 11 0 11 11 0 11 0 11 0 0 11 0 11 0 0 11 0 11 0 0 11 0 11 11 11 11 0 11 0 0 11 0 0 0 0 0 0 11 0 0 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

or = 1 0 0 -1 -1 0 0 1 k = 1 x = 2 y = 10 x = 3 y = 10 x = 4 y = 10 x = 5 y = 10 x = 6 y = 10 x = 7 y = 10 x = 8 y = 10 x = 9 y = 10 k = 2 x = 9 y = 9 x = 9 y = 8 x = 9 y = 7 x = 9 y = 6 x = 9 y = 5 x = 9 y = 4 x = 9 y = 3 k = 3 x = 8 y = 3 x = 7 y = 3 x = 6 y = 3 x = 5 y = 3 x = 4 y = 3 x = 3 y = 3 k = 4 x = 3 y = 4 x = 3 y = 5 x = 3 y = 6 x = 3 y = 7 x = 3 y = 8 k = 1 x = 4 y = 8 x = 5 y = 8 x = 6 y = 8 x = 7 y = 8 k = 2 x = 7 y = 7 x = 7 y = 6 x = 7 y = 5 k = 3 x = 6 y = 5 x = 5 y = 5 k = 4 x = 5 y = 6

7   Pass
n = 17; y_correct =[11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 11 0 0 11 11 11 11 11 11 11 11 11 11 11 11 11 0 11 0 0 11 0 0 0 0 0 0 0 0 0 0 0 11 0 11 0 0 11 0 11 11 11 11 11 11 11 11 11 0 11 0 11 0 0 11 0 11 0 0 0 0 0 0 0 11 0 11 0 11 0 0 11 0 11 0 11 11 11 11 11 0 11 0 11 0 11 0 0 11 0 11 0 11 0 0 0 11 0 11 0 11 0 11 0 0 11 0 11 0 11 0 11 0 11 0 11 0 11 0 11 0 0 11 0 11 0 11 0 11 11 11 0 11 0 11 0 11 0 0 11 0 11 0 11 0 0 0 0 0 11 0 11 0 11 0 0 11 0 11 0 11 11 11 11 11 11 11 0 11 0 11 0 0 11 0 11 0 0 0 0 0 0 0 0 0 11 0 11 0 0 11 0 11 11 11 11 11 11 11 11 11 11 11 0 11 0 0 11 0 0 0 0 0 0 0 0 0 0 0 0 0 11 0 0 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]; assert(isequal(Matrix_Spiral(n),y_correct))

or = 1 0 0 -1 -1 0 0 1 k = 1 x = 2 y = 17 x = 3 y = 17 x = 4 y = 17 x = 5 y = 17 x = 6 y = 17 x = 7 y = 17 x = 8 y = 17 x = 9 y = 17 x = 10 y = 17 x = 11 y = 17 x = 12 y = 17 x = 13 y = 17 x = 14 y = 17 x = 15 y = 17 x = 16 y = 17 k = 2 x = 16 y = 16 x = 16 y = 15 x = 16 y = 14 x = 16 y = 13 x = 16 y = 12 x = 16 y = 11 x = 16 y = 10 x = 16 y = 9 x = 16 y = 8 x = 16 y = 7 x = 16 y = 6 x = 16 y = 5 x = 16 y = 4 x = 16 y = 3 k = 3 x = 15 y = 3 x = 14 y = 3 x = 13 y = 3 x = 12 y = 3 x = 11 y = 3 x = 10 y = 3 x = 9 y = 3 x = 8 y = 3 x = 7 y = 3 x = 6 y = 3 x = 5 y = 3 x = 4 y = 3 x = 3 y = 3 k = 4 x = 3 y = 4 x = 3 y = 5 x = 3 y = 6 x = 3 y = 7 x = 3 y = 8 x = 3 y = 9 x = 3 y = 10 x = 3 y = 11 x = 3 y = 12 x = 3 y = 13 x = 3 y = 14 x = 3 y = 15 k = 1 x = 4 y = 15 x = 5 y = 15 x = 6 y = 15 x = 7 y = 15 x = 8 y = 15 x = 9 y = 15 x = 10 y = 15 x = 11 y = 15 x = 12 y = 15 x = 13 y = 15 x = 14 y = 15 k = 2 x = 14 y = 14 x = 14 y = 13 x = 14 y = 12 x = 14 y = 11 x = 14 y = 10 x = 14 y = 9 x = 14 y = 8 x = 14 y = 7 x = 14 y = 6 x = 14 y = 5 k = 3 x = 13 y = 5 x = 12 y = 5 x = 11 y = 5 x = 10 y = 5 x = 9 y = 5 x = 8 y = 5 x = 7 y = 5 x = 6 y = 5 x = 5 y = 5 k = 4 x = 5 y = 6 x = 5 y = 7 x = 5 y = 8 x = 5 y = 9 x = 5 y = 10 x = 5 y = 11 x = 5 y = 12 x = 5 y = 13 k = 1 x = 6 y = 13 x = 7 y = 13 x = 8 y = 13 x = 9 y = 13 x = 10 y = 13 x = 11 y = 13 x = 12 y = 13 k = 2 x = 12 y = 12 x = 12 y = 11 x = 12 y = 10 x = 12 y = 9 x = 12 y = 8 x = 12 y = 7 k = 3 x = 11 y = 7 x = 10 y = 7 x = 9 y = 7 x = 8 y = 7 x = 7 y = 7 k = 4 x = 7 y = 8 x = 7 y = 9 x = 7 y = 10 x = 7 y = 11 k = 1 x = 8 y = 11 x = 9 y = 11 x = 10 y = 11 k = 2 x = 10 y = 10 x = 10 y = 9 k = 3 x = 9 y = 9