Your test suite doesn't really match the problem statement. The tests require matrices with *exactly* all elements abot the main diagonal to be 0 *and* all elements on or below the main diagonal to be 1.
Additional test cases have been added.
Running this on octave returns the correct results yet the page still says I'm wrong.
function y = triangMatrix(x)
for i=1:rows(x);
for j=1:columns(x);
if j>i;
x(i,j)=0;
else
endif
endfor
endfor
disp(x)
endfunction
I copied this code from somewhere.
Which values occur exactly three times?
3817 Solvers
Number of 1s in the Binary Representation of a Number
356 Solvers
Project Euler: Problem 8, Find largest product in a large string of numbers
315 Solvers
Magic is simple (for beginners)
2754 Solvers
531 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!