Cody

Solution 2607064

Submitted on 24 Jun 2020 by Mike Haddad
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.2862 0.7179 0.6494 0.7067 0.3376 0.0899 0.1303 0.9778 0.5029 0.4091 0.8057 0.0440 0.4972 0.0844 0.9273 mat = 0 1.0000 2.0000 3.0000 1.0000 0 0.0899 0.1303 0.9778 0.5029 0.4091 0.8057 0.0440 0.4972 0.0844 0.9273 mat = 0 1.0000 2.0000 3.0000 1.0000 0 1.0000 2.0000 2.0000 1.0000 0 0.8057 0.0440 0.4972 0.0844 0.9273 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.8135 0.9879 0.6898 0.6130 0.1551 0.6159 0.6353 0.9615 0.5037 0.0109 0.8272 0.9055 0.6885 0.3459 0.4826 0.3390 0.6240 0.6464 0.7140 0.5100 0.7346 0.3985 0.7521 0.5367 mat = 0 1.0000 2.0000 3.0000 4.0000 1.0000 0 0.6353 0.9615 0.5037 0.0109 0.8272 0.9055 0.6885 0.3459 0.4826 0.3390 0.6240 0.6464 0.7140 0.5100 0.7346 0.3985 0.7521 0.5367 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.6885 0.3459 0.4826 0.3390 0.6240 0.6464 0.7140 0.5100 0.7346 0.3985 0.7521 0.5367 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.7140 0.5100 0.7346 0.3985 0.7521 0.5367 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