Cody

Solution 1954473

Submitted on 1 Oct 2019 by Doan Quang Manh
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
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))

a = 1 1 1 1 a = 0 1 1 1 x = 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 1 1 1 1 a = 0 0 1 1 x = 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 a = 1 1 1 1 a = 0 0 0 1 x = 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 y = 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1

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

a = 1 1 1 1 1 a = 0 1 1 1 1 x = 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 1 1 1 1 1 a = 0 0 1 1 1 x = 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 a = 1 1 1 1 1 a = 0 0 0 1 1 x = 1 0 0 0 1 1 1 0 0 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 a = 1 1 1 1 1 a = 0 0 0 0 1 x = 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 y = 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

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

a = 5 6 7 8 a = 0 6 7 8 x = 1 0 9 13 2 6 10 14 3 7 11 15 4 8 12 16 a = 9 10 11 12 a = 0 0 11 12 x = 1 0 0 13 2 6 0 14 3 7 11 15 4 8 12 16 a = 13 14 15 16 a = 0 0 0 16 x = 1 0 0 0 2 6 0 0 3 7 11 0 4 8 12 16 y = 1 0 0 0 2 6 0 0 3 7 11 0 4 8 12 16

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

a = 1 0 0 0 a = 0 0 0 0 x = 0 0 2 3 0 0 1 2 0 0 0 1 0 0 0 0 a = 2 1 0 0 a = 0 0 0 0 x = 0 0 0 3 0 0 0 2 0 0 0 1 0 0 0 0 a = 3 2 1 0 a = 0 0 0 0 x = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 y = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0