Cody

Problem 44468. Diagonal Pattern

Solution 2776756

Submitted on 4 Aug 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
filetext = fileread('diagonalPattern.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

Error using fileread (line 23) Could not open file diagonalPattern.m. No such file or directory. Error in Test1 (line 1) filetext = fileread('diagonalPattern.m');

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

Undefined function 'diagonalPattern' for input arguments of type 'double'. Error in Test2 (line 3) assert(isequal(diagonalPattern(n),mat_correct))

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

Undefined function 'diagonalPattern' for input arguments of type 'double'. Error in Test3 (line 3) assert(isequal(diagonalPattern(n),mat_correct))

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

Undefined function 'diagonalPattern' for input arguments of type 'double'. Error in Test4 (line 3) assert(isequal(diagonalPattern(n),mat_correct))

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

Undefined function 'diagonalPattern' for input arguments of type 'double'. Error in Test5 (line 6) assert(isequal(diagonalPattern(n),mat_correct))

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

Undefined function 'diagonalPattern' for input arguments of type 'double'. Error in Test6 (line 7) assert(isequal(diagonalPattern(n),mat_correct))