Cody

# Problem 44469. Diagonal Pattern

Solution 2551170

Submitted on 14 Jun 2020 by Vlad Levin
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))

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

0 1 3 3 2 3 1 1 1 4 4 4 2 2 3 1 0 1 3 3 1 3 1 1 1 4 4 4 2 2 3 1 0 1 3 3 1 3 1 1 2 4 4 4 2 2 3 1 0 1 3 3 1 3 1 1 2 4 4 4 3 2 3 1 0 1 3 3 1 3 1 1 2 4 4 4 3 2 3 1 0 1 3 3 1 0 1 1 2 4 4 4 3 2 3 1 0 1 3 3 1 0 1 1 2 1 4 4 3 2 3 1 0 1 3 3 1 0 1 1 2 1 4 4 3 2 3 1 0 1 2 3 1 0 1 1 2 1 4 4 3 2 3 1 0 1 2 3 1 0 1 1 2 1 4 4 3 2 3 1 0 1 2 3 1 0 1 1 2 1 0 4 3 2 3 1 0 1 2 3 1 0 1 1 2 1 0 4 3 2 1 1 0 1 2 3 1 0 1 1 2 1 0 4 3 2 1 1 0 1 2 3 1 0 1 2 2 1 0 4 3 2 1 1 0 1 2 3 1 0 1 2 2 1 0 1 3 2 1 1 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))

0 3 4 4 4 4 2 2 3 3 2 3 4 5 1 1 4 3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