Cody

# Problem 579. Spiral In

Solution 2764957

Submitted on 31 Jul 2020
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
m = 3; n = 5; s_correct = [1 12 11 10 9; 2 13 14 15 8; 3 4 5 6 7]; assert(isequal(spiralIn(m,n),s_correct))

2   Pass
m = 5; n = 3; s_correct = [1 12 11; 2 13 10; 3 14 9; 4 15 8; 5 6 7]; assert(isequal(spiralIn(m,n),s_correct))

3   Fail
m = 1; n = 1; s_correct = 1; assert(isequal(spiralIn(m,n),s_correct))

Index in position 1 exceeds array bounds (must not exceed 1). Error in spiralIn>fillmatrix (line 7) if s(i,j) Error in spiralIn>fillmatrix (line 24) s = fillmatrix(s,v+1,a,b,a,b,c,d); Error in spiralIn (line 3) s = fillmatrix(s,1,1,1,1,1,m,n); Error in Test3 (line 4) assert(isequal(spiralIn(m,n),s_correct))

4   Fail
m = 5; n = 0; s_correct = zeros(5,0); assert(isequal(spiralIn(m,n),s_correct))

Index in position 2 exceeds array bounds. Error in spiralIn>fillmatrix (line 7) if s(i,j) Error in spiralIn (line 3) s = fillmatrix(s,1,1,1,1,1,m,n); Error in Test4 (line 4) assert(isequal(spiralIn(m,n),s_correct))

5   Pass
m = 2; n = 2; s_correct = [1 4; 2 3]; assert(isequal(spiralIn(m,n),s_correct))