Cody

Solution 1545652

Submitted on 1 Jun 2018 by yuri pahomov
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
filetext = fileread('diagonalPattern.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Pass
n = 1; mat_correct = 0; assert(isequal(diagonalPattern(n),mat_correct))

mat = 0

3   Pass
n = -1; mat_correct = []; assert(isequal(diagonalPattern(n),mat_correct))

mat = []

4   Pass
n = 1.5; mat_correct = []; assert(isequal(diagonalPattern(n),mat_correct))

mat = []

5   Pass
n = 4; mat_correct = [0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0]; assert(isequal(diagonalPattern(n),mat_correct))

i = 2 mat = 0 1 i = 3 mat = 0 1 2 i = 4 mat = 0 1 2 3 i = 5 mat = 0 1 1 0 2 0 3 0 i = 6 r = 2 mat = 0 1 1 0 2 0 3 0 i = 7 mat = 0 1 1 0 2 1 3 0 i = 8 mat = 0 1 1 0 2 1 3 2 i = 9 mat = 0 1 2 1 0 0 2 1 0 3 2 0 i = 10 mat = 0 1 2 1 0 1 2 1 0 3 2 0 i = 11 r = 3 mat = 0 1 2 1 0 1 2 1 0 3 2 0 i = 12 mat = 0 1 2 1 0 1 2 1 0 3 2 1 i = 13 mat = 0 1 2 3 1 0 1 0 2 1 0 0 3 2 1 0 i = 14 mat = 0 1 2 3 1 0 1 2 2 1 0 0 3 2 1 0 i = 15 mat = 0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0 i = 16 r = 4 mat = 0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0

6   Pass
n = 5; mat_correct = [0 1 2 3 4 1 0 1 2 3 2 1 0 1 2 3 2 1 0 1 4 3 2 1 0]; assert(isequal(diagonalPattern(n),mat_correct))

i = 2 mat = 0 1 i = 3 mat = 0 1 2 i = 4 mat = 0 1 2 3 i = 5 mat = 0 1 2 3 4 i = 6 mat = 0 1 1 0 2 0 3 0 4 0 i = 7 r = 2 mat = 0 1 1 0 2 0 3 0 4 0 i = 8 mat = 0 1 1 0 2 1 3 0 4 0 i = 9 mat = 0 1 1 0 2 1 3 2 4 0 i = 10 mat = 0 1 1 0 2 1 3 2 4 3 i = 11 mat = 0 1 2 1 0 0 2 1 0 3 2 0 4 3 0 i = 12 mat = 0 1 2 1 0 1 2 1 0 3 2 0 4 3 0 i = 13 r = 3 mat = 0 1 2 1 0 1 2 1 0 3 2 0 4 3 0 i = 14 mat = 0 1 2 1 0 1 2 1 0 3 2 1 4 3 0 i = 15 mat = 0 1 2 1 0 1 2 1 0 3 2 1 4 3 2 i = 16 mat = 0 1 2 3 1 0 1 0 2 1 0 0 3 2 1 0 4 3 2 0 i = 17 mat = 0 1 2 3 1 0 1 2 2 1 0 0 3 2 1 0 4 3 2 0 i = 18 mat = 0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0 4 3 2 0 i = 19 r = 4 mat = 0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0 4 3 2 0 i = 20 mat = 0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 0 4 3 2 1 i = 21 mat = 0 1 2 3 4 1 0 1 2 0 2 1 0 1 0 3 2 1 0 0 4 3 2 1 0 i = 22 mat = 0 1 2 3 4 1 0 1 2 3 2 1 0 1 0 3 2 1 0 0 4 3 2 1 0 i = 23 mat = 0 1 2 3 4 1 0 1 2 3 2 1 0 1 2 3 2 1 0 0 4 3 2 1 0 i = 24 mat = 0 1 2 3 4 1 0 1 2 3 2 1 0 1 2 3 2 1 0 1 4 3 2 1 0 i = 25 r = 5 mat = 0 1 2 3 4 1 0 1 2 3 2 1 0 1 2 3 2 1 0 1 4 3 2 1 0

Suggested Problems

More from this Author25