Cody

Problem 1704. Triangular matrices in 3D array

Solution 276891

Submitted on 9 Jul 2013 by Evan
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(:,:,1) = [1 2 3;4 5 6;7 8 9]; x(:,:,2) = [1 4 7;2 5 8;3 6 9]; x(:,:,3) = [1 2 3;1 2 3;1 2 3]; y_correct(:,:,1) = [1 0 0;4 5 0;7 8 9]; y_correct(:,:,2) = [1 0 0;2 5 0;3 6 9]; y_correct(:,:,3) = [1 0 0;1 2 0;1 2 3]; assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 1 0 0 4 5 0 7 8 9 ans(:,:,2) = 1 0 0 2 5 0 3 6 9 ans(:,:,3) = 1 0 0 1 2 0 1 2 3

2   Pass
%% x = cumsum(ones(3,3,50)); y_correct = repmat([1 0 0;2 2 0; 3 3 3],[1,1,50]); assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 1 0 0 2 2 0 3 3 3 ans(:,:,2) = 1 0 0 2 2 0 3 3 3 ans(:,:,3) = 1 0 0 2 2 0 3 3 3 ans(:,:,4) = 1 0 0 2 2 0 3 3 3 ans(:,:,5) = 1 0 0 2 2 0 3 3 3 ans(:,:,6) = 1 0 0 2 2 0 3 3 3 ans(:,:,7) = 1 0 0 2 2 0 3 3 3 ans(:,:,8) = 1 0 0 2 2 0 3 3 3 ans(:,:,9) = 1 0 0 2 2 0 3 3 3 ans(:,:,10) = 1 0 0 2 2 0 3 3 3 ans(:,:,11) = 1 0 0 2 2 0 3 3 3 ans(:,:,12) = 1 0 0 2 2 0 3 3 3 ans(:,:,13) = 1 0 0 2 2 0 3 3 3 ans(:,:,14) = 1 0 0 2 2 0 3 3 3 ans(:,:,15) = 1 0 0 2 2 0 3 3 3 ans(:,:,16) = 1 0 0 2 2 0 3 3 3 ans(:,:,17) = 1 0 0 2 2 0 3 3 3 ans(:,:,18) = 1 0 0 2 2 0 3 3 3 ans(:,:,19) = 1 0 0 2 2 0 3 3 3 ans(:,:,20) = 1 0 0 2 2 0 3 3 3 ans(:,:,21) = 1 0 0 2 2 0 3 3 3 ans(:,:,22) = 1 0 0 2 2 0 3 3 3 ans(:,:,23) = 1 0 0 2 2 0 3 3 3 ans(:,:,24) = 1 0 0 2 2 0 3 3 3 ans(:,:,25) = 1 0 0 2 2 0 3 3 3 ans(:,:,26) = 1 0 0 2 2 0 3 3 3 ans(:,:,27) = 1 0 0 2 2 0 3 3 3 ans(:,:,28) = 1 0 0 2 2 0 3 3 3 ans(:,:,29) = 1 0 0 2 2 0 3 3 3 ans(:,:,30) = 1 0 0 2 2 0 3 3 3 ans(:,:,31) = 1 0 0 2 2 0 3 3 3 ans(:,:,32) = 1 0 0 2 2 0 3 3 3 ans(:,:,33) = 1 0 0 2 2 0 3 3 3 ans(:,:,34) = 1 0 0 2 2 0 3 3 3 ans(:,:,35) = 1 0 0 2 2 0 3 3 3 ans(:,:,36) = 1 0 0 2 2 0 3 3 3 ans(:,:,37) = 1 0 0 2 2 0 3 3 3 ans(:,:,38) = 1 0 0 2 2 0 3 3 3 ans(:,:,39) = 1 0 0 2 2 0 3 3 3 ans(:,:,40) = 1 0 0 2 2 0 3 3 3 ans(:,:,41) = 1 0 0 2 2 0 3 3 3 ans(:,:,42) = 1 0 0 2 2 0 3 3 3 ans(:,:,43) = 1 0 0 2 2 0 3 3 3 ans(:,:,44) = 1 0 0 2 2 0 3 3 3 ans(:,:,45) = 1 0 0 2 2 0 3 3 3 ans(:,:,46) = 1 0 0 2 2 0 3 3 3 ans(:,:,47) = 1 0 0 2 2 0 3 3 3 ans(:,:,48) = 1 0 0 2 2 0 3 3 3 ans(:,:,49) = 1 0 0 2 2 0 3 3 3 ans(:,:,50) = 1 0 0 2 2 0 3 3 3

3   Pass
%% x = cumsum(ones(5,5,100),2); y_correct = repmat(tril(cumsum(ones(5,5),2)),[1,1,100]); assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 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(:,:,52) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,53) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,54) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,55) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,56) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,57) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,58) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,59) = 1 0 0 0 0 1 2 0 0 0 1 2 3 0 0 1 2 3 4 0 1 2 3 4 5 ans(:,:,60) = 1 0 0 ...

4   Pass
%% x = rand([1 1 400]); y_correct = x; assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 0.7574 ans(:,:,2) = 0.2083 ans(:,:,3) = 0.6130 ans(:,:,4) = 0.7048 ans(:,:,5) = 0.8538 ans(:,:,6) = 0.4915 ans(:,:,7) = 0.8624 ans(:,:,8) = 0.6832 ans(:,:,9) = 0.1220 ans(:,:,10) = 0.9384 ans(:,:,11) = 0.0069 ans(:,:,12) = 0.1625 ans(:,:,13) = 0.6314 ans(:,:,14) = 0.2060 ans(:,:,15) = 0.6816 ans(:,:,16) = 0.5504 ans(:,:,17) = 0.7829 ans(:,:,18) = 0.2709 ans(:,:,19) = 0.2495 ans(:,:,20) = 0.9355 ans(:,:,21) = 0.1500 ans(:,:,22) = 0.2232 ans(:,:,23) = 0.5695 ans(:,:,24) = 0.6688 ans(:,:,25) = 0.2858 ans(:,:,26) = 0.5243 ans(:,:,27) = 0.2203 ans(:,:,28) = 0.5656 ans(:,:,29) = 0.3648 ans(:,:,30) = 0.4901 ans(:,:,31) = 0.4394 ans(:,:,32) = 0.9343 ans(:,:,33) = 0.9450 ans(:,:,34) = 0.8489 ans(:,:,35) = 0.1015 ans(:,:,36) = 0.8250 ans(:,:,37) = 0.2876 ans(:,:,38) = 0.5273 ans(:,:,39) = 0.1030 ans(:,:,40) = 0.4515 ans(:,:,41) = 0.3019 ans(:,:,42) = 0.6161 ans(:,:,43) = 0.3586 ans(:,:,44) = 0.6113 ans(:,:,45) = 0.8532 ans(:,:,46) = 0.8539 ans(:,:,47) = 0.5465 ans(:,:,48) = 0.6389 ans(:,:,49) = 0.3159 ans(:,:,50) = 0.0779 ans(:,:,51) = 0.0117 ans(:,:,52) = 0.6373 ans(:,:,53) = 0.4811 ans(:,:,54) = 0.0464 ans(:,:,55) = 0.5505 ans(:,:,56) = 0.3428 ans(:,:,57) = 0.0202 ans(:,:,58) = 0.6446 ans(:,:,59) = 0.5496 ans(:,:,60) = 0.4149 ans(:,:,61) = 0.8047 ans(:,:,62) = 0.1586 ans(:,:,63) = 0.7522 ans(:,:,64) = 0.4874 ans(:,:,65) = 0.4203 ans(:,:,66) = 0.6812 ans(:,:,67) = 0.9943 ans(:,:,68) = 0.9831 ans(:,:,69) = 0.9981 ans(:,:,70) = 0.5199 ans(:,:,71) = 0.6647 ans(:,:,72) = 0.8105 ans(:,:,73) = 0.2273 ans(:,:,74) = 0.6712 ans(:,:,75) = 0.5186 ans(:,:,76) = 0.2413 ans(:,:,77) = 0.4384 ans(:,:,78) = 0.6226 ans(:,:,79) = 0.6633 ans(:,:,80) = 0.6531 ans(:,:,81) = 0.9197 ans(:,:,82) = 0.6072 ans(:,:,83) = 0.0570 ans(:,:,84) = 0.4153 ans(:,:,85) = 0.4730 ans(:,:,86) = 0.2829 ans(:,:,87) = 0.2712 ans(:,:,88) = 0.5832 ans(:,:,89) = 0.5354 ans(:,:,90) = 0.3591 ans(:,:,91) = 0.5482 ans(:,:,92) = 0.0909 ans(:,:,93) = 0.2868 ans(:,:,94) = 0.4918 ans(:,:,95) = 0.5599 ans(:,:,96) = 0.4213 ans(:,:,97) = 0.5112 ans(:,:,98) = 0.3959 ans(:,:,99) = 0.1487 ans(:,:,100) = 0.8846 ans(:,:,101) = 0.3547 ans(:,:,102) = 0.5823 ans(:,:,103) = 0.5884 ans(:,:,104) = 0.6297 ans(:,:,105) = 0.6047 ans(:,:,106) = 0.7086 ans(:,:,107) = 0.7214 ans(:,:,108) = 0.4125 ans(:,:,109) = 0.1856 ans(:,:,110) = 0.0239 ans(:,:,111) = 0.4058 ans(:,:,112) = 0.8659 ans(:,:,113) = 0.8749 ans(:,:,114) = 0.8062 ans(:,:,115) = 0.5464 ans(:,:,116) = 0.6897 ans(:,:,117) = 0.6790 ans(:,:,118) = 0.8124 ans(:,:,119) = 0.1306 ans(:,:,120) = 0.1697 ans(:,:,121) = 0.7017 ans(:,:,122) = 0.3515 ans(:,:,123) = 0.6298 ans(:,:,124) = 0.8298 ans(:,:,125) = 0.2577 ans(:,:,126) = 0.8668 ans(:,:,127) = 0.9511 ans(:,:,128) = 0.4555 ans(:,:,129) = 0.3262 ans(:,:,130) = 0.1578 ans(:,:,131) = 0.8101 ans(:,:,132) = 0.8063 ans(:,:,133) = 0.6879 ans(:,:,134) = 0.2238 ans(:,:,135) = 0.3335 ans(:,:,136) = 0.0502 ans(:,:,137) = 0.1661 ans(:,:,138) = 0.3922 ans(:,:,139) = 0.8932 ans(:,:,140) = 0.6634 ans(:,:,141) = 0.3292 ans(:,:,142) = 0.8246 ans(:,:,143) = 0.2422 ans(:,:,144) = 0.9074 ans(:,:,145) = 0.2915 ans(:,:,146) = 0.6232 ans(:,:,147) = 0.8068 ans(:,:,148) = 0.0320 ans(:,:,149) = 0.8793 ans(:,:,150) = 0.9885 ans(:,:,151) = 0.6493 ans(:,:,152) = 0.3787 ans(:,:,153) = 0.7313 ans(:,:,154) = 0.9200 ans(:,:,155) = 0.4954 ans(:,:,156) = 0.1808 ans(:,:,157) = 0.4734 ans(:,:,158) = 0.0714 ans(:,:,159) = 0.9163 ans(:,:,160) = 0.5118 ans(:,:,161) = 0.2546 ans(:,:,162) = 0.4046 ans(:,:,163) = 0.9592 ans(:,:,164) = 0.6571 ans(:,:,165) = 0.7693 ans(:,:,166) = 0.1145 ans(:,:,167) = 0.2640 ans(:,:,168) = 0.8113 ans(:,:,169) = 0.7587 ans(:,:,170) = 0.4232 ans(:,:,171) = 0.6896 ans(:,:,172) = 0.6876 ans(:,:,173) = 0.1828 ans(:,:,174) = 0.0122 ans(:,:,175) = 0.0283 ans(:,:,176) = 0.1015 ans(:,:,177) = 0.8431 ans(:,:,178) = 0.1035 ans(:,:,179) = 0.3207 ans(:,:,180) = 0.7299 ans(:,:,181) = 0.3659 ans(:,:,182) = 0.5102 ans(:,:,183) = 0.2588 ans(:,:,184) = 0.5771 ans(:,:,185) = 0.4676 ans(:,:,186) = 0.7311 ans(:,:,187) = 0.1049 ans(:,:,188) = 0.9797 ans(:,:,189) = 0.4154 ans(:,:,190) = 0.7948 ans(:,:,191) = 0.4309 ans(:,:,192) = 0.8106 ans(:,:,193) = 0.4847 ans(:,:,194) = 0.5390 ans(:,:,195) = 0.0109 ans(:,:,196) = 0.6053 ans(:,:,197) = 0.2297 ans(:,:,198) = 0.6901 ans(:,:,199) = 0.5170 ans(:,:,200) = 0.1963 ans(:,:,201) = 0.8390 ans(:,:,202) = 0.0975 ans(:,:,203) = 0.2709 ans(:,:,204) = 0.4455 ans(:,:,205) = 0.5739 ans(:,:,206) = 0.1073 ans(:,:,207) = 0.1105 ans(:,:,208) = 0.0160 ans(:,:,209) = 0.4254 ans(:,:,210) = 0.3005 ans(:,:,211) = 0.2720 ans(:,:,212) = 0.6557 ans(:,:,213) = 0.7661 ans(:,:,214) = 0.9105 ans(:,:,215) = 0.4790 ans(:,:,216) = 0.8740 ans(:,:,217) = 0.0831 ans(:,:,218) = 0.6741 ans(:,:,219) = 0.7399 ans(:,:,220) = 0.3850 ans(:,:,221) = 0.6589 ans(:,:,222) = 0.0194 ans(:,:,223) = 0.5983 ans(:,:,224) = 0.3344 ans(:,:,225) = 0.1141 ans(:,:,226) = 0.6680 ans(:,:,227) = 0.5431 ans(:,:,228) = 0.1774 ans(:,:,229) = 0.3959 ans(:,:,230) = 0.4922 ans(:,:,231) = 0.4379 ans(:,:,232) = 0.6354 ans(:,:,233) = 0.1527 ans(:,:,234) = 0.9293 ans(:,:,235) = 0.8702 ans(:,:,236) = 0.2656 ans(:,:,237) = 0.5091 ans(:,:,238) = 0.4904 ans(:,:,239) = 0.0415 ans(:,:,240) = 0.4047 ans(:,:,241) = 0.3785 ans(:,:,242) = 0.1669 ans(:,:,243) = 0.8495 ans(:,:,244) = 0.6528 ans(:,:,245) = 0.5188 ans(:,:,246) = 0.7210 ans(:,:,247) = 0.0812 ans(:,:,248) = 0.9277 ans(:,:,249) = 0.0340 ans(:,:,250) = 0.2265 ans(:,:,251) = 0.4998 ans(:,:,252) = 0.1423 ans(:,:,253) = 0.2522 ans(:,:,254) = 0.9082 ans(:,:,255) = 0.5377 ans(:,:,256) = 0.8585 ans(:,:,257) = 0.5233 ans(:,:,258) = 0.8496 ans(:,:,259) = 0.2384 ans(:,:,260) = 0.1158 ans(:,:,261) = 0.6472 ans(:,:,262) = 0.1076 ans(:,:,263) = 0.2855 ans(:,:,264) = 0.0984 ans(:,:,265) = 0.2863 ans(:,:,266) = 0.9124 ans(:,:,267) = 0.5138 ans(:,:,268) = 0.2648 ans(:,:,269) = 0.3425 ans(:,:,270) = 0.4914 ans(:,:,271) = 0.7919 ans(:,:,272) = 0.2568 ans(:,:,273) = 0.6187 ans(:,:,274) = 0.9960 ans(:,:,275) = 0.0135 ans(:,:,276) = 0.4588 ans(:,:,277) = 0.5209 ans(:,:,278) = 0.8773 ans(:,:,279) = 0.1513 ans(:,:,280) = 0.1852 ans(:,:,281) = 0.9299 ans(:,:,282) = 0.7842 ans(:,:,283) = 0.1596 ans(:,:,284) = 0.9367 ans(:,:,285) = 0.0654 ans(:,:,286) = 0.3805 ans(:,:,287) = 0.6920 ans(:,:,288) = 0.0279 ans(:,:,289) = 0.8874 ans(:,:,290) = 0.9166 ans(:,:,291) = 0.4385 ans(:,:,292) = 0.2282 ans(:,:,293) = 0.6091 ans(:,:,294) = 0.9254 ans(:,:,295) = 0.6356 ans(:,:,296) = 0.0548 ans(:,:,297) = 0.9922 ans(:,:,298) = 0.2956 ans(:,:,299) = 0.2401 ans(:,:,300) = 0.3859 ans(:,:,301) = 0.2611 ans(:,:,302) = 0.2247 ans(:,:,303) = 0.3681 ans(:,:,304) = 0.1743 ans(:,:,305) = 0.7681 ans(:,:,306) = 0.5837 ans(:,:,307) = 0.3149 ans(:,:,308) = 0.9043 ans(:,:,309) = 0.8981 ans(:,:,310) = 0.4348 ans(:,:,311) = 0.0706 ans(:,:,312) = 0.6450 ans(:,:,313) = 0.8383 ans(:,:,314) = 0.9037 ans(:,:,315) = 0.6201 ans(:,:,316) = 0.4250 ans(:,:,317) = 0.0059 ans(:,:,318) = 0.9701 ans(:,:,319) = 0.5307 ans(:,:,320) = 0.3407 ans(:,:,321) = 0.5919 ans(:,:,322) = 0.8913 ans(:,:,323) = 0.4535 ans(:,:,324) = 0.6942 ans(:,:,325) = 0.9149 ans(:,:,326) = 0.1114 ans(:,:,327) = 0.2234 ans(:,:,328) = 0.4882 ans(:,:,329) = 0.7983 ans(:,:,330) = 0.4411 ans(:,:,331) = 0.1696 ans(:,:,332) = 0.8831 ans(:,:,333) = 0.0287 ans(:,:,334) = 0.3588 ans(:,:,335) = 0.8642 ans(:,:,336) = 0.7352 ans(:,:,337) = 0.6560 ans(:,:,338) = 0.4961 ans(:,:,339) = 0.0984 ans(:,:,340) = 0.2629 ans(:,:,341) = 0.4641 ans(:,:,342) = 0.5119 ans(:,:,343) = 0.5965 ans(:,:,344) = 0.4706 ans(:,:,345) = 0.4137 ans(:,:,346) = 0.5132 ans(:,:,347) = 0.1568 ans(:,:,348) = 0.2424 ans(:,:,349) = 0.1957 ans(:,:,350) = 0.7000 ans(:,:,351) = 0.5475 ans(:,:,352) = 0.1014 ans(:,:,353) = 0.3475 ans(:,:,354) = 0.8838 ans(:,:,355) = 0.1156 ans(:,:,356) = 0.8697 ans(:,:,357) = 0.7150 ans(:,:,358) = 0.1677 ans(:,:,359) = 0.8828 ans(:,:,360) = 0.0773 ans(:,:,361) = 0.7031 ans(:,:,362) = 0.6695 ans(:,:,363) = 0.6881 ans(:,:,364) = 0.9886 ans(:,:,365) = 0.0603 ans(:,:,366) = 0.6216 ans(:,:,367) = 0.4868 ans(:,:,368) = 0.3047 ans(:,:,369) = 0.1460 ans(:,:,370) = 0.9555 ans(:,:,371) = 0.9605 ans(:,:,372) = 0.8738 ans(:,:,373) = 0.7501 ans(:,:,374) = 0.3799 ans(:,:,375) = 0.6179 ans(:,:,376) = 0.7104 ans(:,:,377) = 0.0583 ans(:,:,378) = 0.5650 ans(:,:,379) = 0.5450 ans(:,:,380) = 0.9739 ans(:,:,381) = 0.1183 ans(:,:,382) = 0.6346 ans(:,:,383) = 0.1474 ans(:,:,384) = 0.2144 ans(:,:,385) = 0.0345 ans(:,:,386) = 0.7741 ans(:,:,387) = 0.2577 ans(:,:,388) = 0.7857 ans(:,:,389) = ...

5   Fail
%% x = reshape(1:40,[2,2,10]); y_correct(:,:,1) = [1 0;2 4]; y_correct(:,:,2) = [5 0;6 8]; y_correct(:,:,3) = [9 0;10 12]; y_correct(:,:,4) = [13 0;14 16]; y_correct(:,:,5) = [17 0;18 20]; y_correct(:,:,6) = [21 0;22 24]; y_correct(:,:,7) = [25 0;26 28]; y_correct(:,:,8) = [29 0;30 32]; y_correct(:,:,9) = [33 0;34 36]; y_correct(:,:,10) = [37 0;38 40]; assert(isequal(tril3(x),y_correct))

ans(:,:,1) = 1 0 2 4 ans(:,:,2) = 5 0 6 8 ans(:,:,3) = 9 0 10 12 ans(:,:,4) = 13 0 14 16 ans(:,:,5) = 17 0 18 20 ans(:,:,6) = 21 0 22 24 ans(:,:,7) = 25 0 26 28 ans(:,:,8) = 29 0 30 32 ans(:,:,9) = 33 0 34 36 ans(:,:,10) =

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!