Cody

# Problem 579. Spiral In

Solution 143105

Submitted on 27 Sep 2012 by James
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))

s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 p = 15 high_val = 12 s = 0 0 0 0 9 0 0 0 0 8 0 0 0 0 7 s = 0 12 11 10 9 0 0 0 0 8 0 0 0 0 7 s = 1 12 11 10 9 2 0 0 0 8 3 0 0 0 7 s = 1 12 11 10 9 2 0 0 0 8 3 4 5 6 7 s = 0 0 0 p = 3 high_val = 4 s = 0 0 3 s = 0 4 3 s = 1 4 3 s = 1 2 3 s = Empty matrix: 0-by-1 p = -1 s = 1 2 3 s = 1 12 11 10 9 2 13 14 15 8 3 4 5 6 7

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))

s = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 p = 15 high_val = 12 s = 0 0 11 0 0 10 0 0 9 0 0 8 0 0 7 s = 0 12 11 0 0 10 0 0 9 0 0 8 0 0 7 s = 1 12 11 2 0 10 3 0 9 4 0 8 5 0 7 s = 1 12 11 2 0 10 3 0 9 4 0 8 5 6 7 s = 0 0 0 p = 3 high_val = 4 s = 5 4 3 s = 5 4 3 s = 1 2 3 s = 1 2 3 s = Empty matrix: 1-by-0 p = -1 s = 1 2 3 s = 1 12 11 2 13 10 3 14 9 4 15 8 5 6 7

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

s = 0 p = 1 s = 1

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

s = Empty matrix: 5-by-0 p = 0

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

s = 0 0 0 0 p = 4 high_val = 4 s = 0 4 0 3 s = 0 4 0 3 s = 1 4 2 3 s = 1 4 2 3 s = [] p = 0 s = 1 4 2 3