Cody

Problem 579. Spiral In

Solution 2122936

Submitted on 9 Feb 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   Fail
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))

m = 7 n = 7 q = 1 24 23 22 21 20 19 2 25 40 39 38 37 18 3 26 41 48 47 36 17 4 27 42 49 46 35 16 5 28 43 44 45 34 15 6 29 30 31 32 33 14 7 8 9 10 11 12 13

Assertion failed.

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

m = 7 n = 7 q = 1 24 23 22 21 20 19 2 25 40 39 38 37 18 3 26 41 48 47 36 17 4 27 42 49 46 35 16 5 28 43 44 45 34 15 6 29 30 31 32 33 14 7 8 9 10 11 12 13

Assertion failed.

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

m = 7 n = 7 q = 1 24 23 22 21 20 19 2 25 40 39 38 37 18 3 26 41 48 47 36 17 4 27 42 49 46 35 16 5 28 43 44 45 34 15 6 29 30 31 32 33 14 7 8 9 10 11 12 13

Assertion failed.

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

m = 7 n = 7 q = 1 24 23 22 21 20 19 2 25 40 39 38 37 18 3 26 41 48 47 36 17 4 27 42 49 46 35 16 5 28 43 44 45 34 15 6 29 30 31 32 33 14 7 8 9 10 11 12 13

Assertion failed.

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

m = 7 n = 7 q = 1 24 23 22 21 20 19 2 25 40 39 38 37 18 3 26 41 48 47 36 17 4 27 42 49 46 35 16 5 28 43 44 45 34 15 6 29 30 31 32 33 14 7 8 9 10 11 12 13

Assertion failed.

Suggested Problems

More from this Author11

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!