Cody

# Problem 413. Back to basics 23 - Triangular matrix

Solution 2065429

Submitted on 20 Dec 2019
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
x = ones(4,4); y_correct = [1 0 0 0; 1 1 0 0; 1 1 1 0; 1 1 1 1]; assert(isequal(triangle(x),y_correct))

Unable to perform assignment because the size of the left side is 1-by-16 and the size of the right side is 1-by-4. Error in triangle (line 8) y(id,:)=uusi_rivi; Error in Test1 (line 3) assert(isequal(triangle(x),y_correct))

2   Fail
x = ones(5,5); y_correct = [1 0 0 0 0; 1 1 0 0 0; 1 1 1 0 0; 1 1 1 1 0; 1 1 1 1 1]; assert(isequal(triangle(x),y_correct))

Unable to perform assignment because the size of the left side is 1-by-25 and the size of the right side is 1-by-5. Error in triangle (line 8) y(id,:)=uusi_rivi; Error in Test2 (line 3) assert(isequal(triangle(x),y_correct))

3   Fail
x = reshape(1:16,[4,4]); y_correct = [1 2 3 4; 0 6 7 8; 0 0 11 12; 0 0 0 16]'; assert(isequal(triangle(x),y_correct))

Unable to perform assignment because the size of the left side is 1-by-16 and the size of the right side is 1-by-4. Error in triangle (line 8) y(id,:)=uusi_rivi; Error in Test3 (line 3) assert(isequal(triangle(x),y_correct))

4   Fail
x = [0 1 2 3; 0 0 1 2; 0 0 0 1; 0 0 0 0]; y_correct = zeros(4); assert(isequal(triangle(x),y_correct))

Unable to perform assignment because the size of the left side is 1-by-16 and the size of the right side is 1-by-4. Error in triangle (line 8) y(id,:)=uusi_rivi; Error in Test4 (line 3) assert(isequal(triangle(x),y_correct))