Cody

# Problem 44469. Diagonal Pattern

Solution 2068217

Submitted on 24 Dec 2019 by deeb armaly
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))

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

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

mat = 0 0.8411 0.4519 0.2596 0.4720 0.4052 0.4000 0.0043 0.9181 0.7667 0.5089 0.3512 0.8843 0.2192 0.7542 0.6529 mat = 0 1.0000 2.0000 3.0000 1.0000 0 0.4000 0.0043 0.9181 0.7667 0.5089 0.3512 0.8843 0.2192 0.7542 0.6529 mat = 0 1.0000 2.0000 3.0000 1.0000 0 1.0000 2.0000 2.0000 1.0000 0 0.3512 0.8843 0.2192 0.7542 0.6529 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))

mat = 0 0.6785 0.2166 0.4323 0.3079 0.3562 0.4563 0.0946 0.3605 0.8921 0.1011 0.7843 0.2621 0.8555 0.7552 0.7163 0.2767 0.2853 0.8638 0.5013 0.8016 0.7120 0.2723 0.7433 0.1377 mat = 0 1.0000 2.0000 3.0000 4.0000 1.0000 0 0.0946 0.3605 0.8921 0.1011 0.7843 0.2621 0.8555 0.7552 0.7163 0.2767 0.2853 0.8638 0.5013 0.8016 0.7120 0.2723 0.7433 0.1377 mat = 0 1.0000 2.0000 3.0000 4.0000 1.0000 0 1.0000 2.0000 3.0000 2.0000 1.0000 0 0.8555 0.7552 0.7163 0.2767 0.2853 0.8638 0.5013 0.8016 0.7120 0.2723 0.7433 0.1377 mat = 0 1.0000 2.0000 3.0000 4.0000 1.0000 0 1.0000 2.0000 3.0000 2.0000 1.0000 0 1.0000 2.0000 3.0000 2.0000 1.0000 0 0.5013 0.8016 0.7120 0.2723 0.7433 0.1377 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