Cody

Solution 1516876

Submitted on 4 May 2018
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('triangle.m'); assert(isempty(strfind(filetext, 'regexp')),'regexp hacks are forbidden')

2   Fail
n = 0; mat_correct = []; assert(isequal(triangle(n),mat_correct))

Error using find Option must be of char type. Error in triangle (line 4) m = find(b,1,1); Error in Test2 (line 3) assert(isequal(triangle(n),mat_correct))

3   Fail
n = 1; mat_correct = 1; assert(isequal(triangle(n),mat_correct))

Error using find Option must be of char type. Error in triangle (line 4) m = find(b,1,1); Error in Test3 (line 3) assert(isequal(triangle(n),mat_correct))

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

Error using find Option must be of char type. Error in triangle (line 4) m = find(b,1,1); Error in Test4 (line 3) assert(isequal(triangle(n),mat_correct))

5   Fail
n = 12; mat_correct = [1 0 0 0; 2 3 0 0; 4 5 6 0; 7 8 9 10; 11 12 0 0]; assert(isequal(triangle(n),mat_correct))

Error using find Option must be of char type. Error in triangle (line 4) m = find(b,1,1); Error in Test5 (line 3) assert(isequal(triangle(n),mat_correct))

6   Fail
n = 50; mat_correct = [1,zeros(1,8); 2:3,zeros(1,7); 4:6,zeros(1,6); 7:10,zeros(1,5); 11:15,zeros(1,4); 16:21,zeros(1,3); 22:28,0,0; ; 29:36,0; 37:45; 46:50,zeros(1,4)]; assert(isequal(triangle(n),mat_correct))

Error using find Option must be of char type. Error in triangle (line 4) m = find(b,1,1); Error in Test6 (line 5) assert(isequal(triangle(n),mat_correct))