Cody

# Problem 1400. Spiral Matrix

Solution 1710337

Submitted on 19 Jan 2019 by HH
• Size: 9
• This is the leading solution.
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=2; y_correct=[3 2 4 1]; assert(isequal(spiralmatrix(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In spiralmatrix (line 2) In ScoringEngineTestPoint1 (line 7) In solutionTest (line 5)]

2   Pass
x=3; y_correct=[7 6 5 8 1 4 9 2 3]; assert(isequal(spiralmatrix(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In spiralmatrix (line 2) In ScoringEngineTestPoint2 (line 9) In solutionTest (line 7)]

3   Pass
x=4; y_correct=[13 12 11 10 14 3 2 9 15 4 1 8 16 5 6 7]; assert(isequal(spiralmatrix(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In spiralmatrix (line 2) In ScoringEngineTestPoint3 (line 11) In solutionTest (line 9)]

4   Pass
x=5; y_correct=[21 20 19 18 17 22 7 6 5 16 23 8 1 4 15 24 9 2 3 14 25 10 11 12 13]; assert(isequal(spiralmatrix(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In spiralmatrix (line 2) In ScoringEngineTestPoint4 (line 13) In solutionTest (line 11)]