Cody

Solution 2036783

Submitted on 27 Nov 2019 by Benjamin Richards
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
A = [15 13 3]; y_correct = [15 0 3]; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 15 0 3

2   Pass
A = 13; y_correct = 0; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 0

3   Pass
A = []; y_correct = []; assert(isequal(your_fcn_name(A),y_correct)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = []

4   Pass
A = [13 0 13; 13 13 8; 13 25 2]; titi = [0 0 0 ; 0 0 8;0 25 2]; assert(isequal(your_fcn_name(A),titi)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 0 0 0 0 0 8 0 25 2

5   Pass
A=rand(10,10,10); A(1,2,2)=13; A(3,4,1)=13; A(5,6,3)=13; % what you cannot do but me I can ;) ! titi = A; I=find(titi==13); [u,v,w]=ind2sub(size(titi),I); for ii = 1 : numel(u) titi(u(ii),v(ii),w(ii))=0; end assert(isequal(your_fcn_name(A),titi)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B(:,:,1) = 0.5241 0.9185 0.8880 0.3849 0.5803 0.1560 0.6118 0.0806 0.3866 0.4830 0.4014 0.1069 0.8876 0.2759 0.0270 0.6390 0.8269 0.8612 0.5193 0.9532 0.8311 0.7592 0.2164 0 0.0038 0.1575 0.4528 0.9177 0.3934 0.4975 0.4795 0.1224 0.4443 0.3501 0.9743 0.3144 0.2457 0.4409 0.5731 0.4529 0.3914 0.4324 0.0031 0.2930 0.1988 0.0714 0.0312 0.1300 0.5707 0.3293 0.0431 0.3885 0.3143 0.1961 0.8244 0.9732 0.1596 0.6409 0.9387 0.1834 0.5090 0.6328 0.9464 0.5216 0.2916 0.5926 0.9208 0.7414 0.9012 0.8007 0.7161 0.3873 0.6782 0.2492 0.4494 0.7541 0.1656 0.4995 0.8011 0.2097 0.8180 0.4060 0.6097 0.0070 0.7127 0.5458 0.7980 0.7983 0.5652 0.1258 0.2135 0.8575 0.3379 0.6612 0.8490 0.1593 0.0185 0.8418 0.8951 0.9033 B(:,:,2) = 0.6183 0 0.2504 0.8371 0.2093 0.6780 0.2277 0.0692 0.8607 0.9966 0.0486 0.8226 0.3279 0.9889 0.1395 0.5329 0.5024 0.9791 0.0040 0.7466 0.6943 0.5837 0.1527 0.0179 0.6496 0.5091 0.6058 0.7851 0.9550 0.9664 0.3837 0.7135 0.9681 0.8881 0.9582 0.2637 0.9912 0.5324 0.5815 0.7033 0.9077 0.2319 0.0810 0.1099 0.6518 0.5547 0.2842 0.2569 0.6198 0.9300 0.7527 0.1767 0.7075 0.2308 0.7100 0.4629 0.3574 0.4743 0.1222 0.5405 0.9081 0.8865 0.5792 0.1579 0.6849 0.0187 0.3970 0.5498 0.7131 0.0890 0.1271 0.2204 0.5082 0.3497 0.7478 0.2037 0.6198 0.6454 0.5820 0.6632 0.0668 0.4177 0.7017 0.2711 0.7331 0.0443 0.2749 0.9400 0.2294 0.3665 0.6465 0.8241 0.5206 0.2338 0.6602 0.2211 0.7822 0.8783 0.8232 0.4377 B(:,:,3) = 0.8594 0.5633 0.1115 0.2602 0.2224 0.9356 0.1221 0.1957 0.5325 0.1826 0.1324 0.7298 0.3077 0.6588 0.2004 0.9677 0.4074 0.2541 0.4136 0.0566 0.6993 0.3409 0.0863 0.9337 0.8279 0.2988 0.9346 0.7205 0.3198 0.9412 0.2506 0.9270 0.6063 0.4018 0.9834 0.0417 0.0519 0.5033 0.1571 0.8891 0.6283 0.1576 0.5010 0.3957 0.3965 0 0.2273 0.8742 0.3326 0.6253 0.6191 0.9571 0.0050 0.2104 0.4600 0.6606 0.7408 0.9539 0.1033 0.9814 0.7948 0.5851 0.4277 0.7648 0.8505 0.0666 0.8943 0.5183 0.4740 0.4317 0.9143 0.7216 0.2659 0.1003 0.2370 0.9426 0.2898 0.8919 0.7798 0.3772 0.2295 0.4900 0.4670 0.6246 0.2952 0.3291 0.5694 0.1880 0.7981 0.9355 0.0635 0.1268 0.8388 0.4786 0.3206 0.7582 0.5952 0.4888 0.3807 0.7332 B(:,:,4) = 0.6289 0.6890 0.9869 0.3979 0.0205 0.2885 0.0280 0.3978 0.1489 0.9134 0.1204 0.9197 0.7430 0.1104 0.9278 0.4154 0.2022 0.7782 0.2830 0.6145 0.9126 0.8738 0.0467 0.6879 0.2891 0.6496 0.5256 0.3520 0.3884 0.3565 0.4544 0.8656 0.3403 0.3518 0.0868 0.6700 0.6161 0.8270 0.2896 0.2830 0.4339 0.8021 0.2609 0.4973 0.0988 0.8397 0.3259 0.9041 0.0706 0.9863 0.0037 0.6292 0.6114 0.7746 0.4492 0.6642 0.2002 0.7765 0.3063 0.2699 0.3149 0.6748 0.8120 0.6244 0.7759 0.1527 0.2436 0.7081 0.6518 0.7947 0.3093 0.9304 0.8901 0.3222 0.4216 0.7140 0.7039 0.0904 0.0258 0.3356 0.3747 0.2324 0.8872 0.6985 0.6507 0.5681 0.2299 0.9914 0.0832 0.4682 0.1861 0.9613 0.5423 0.5100 0.2736 0.4872 0.3593 0.7012 0.7574 0.3721 B(:,:,5) = 0.9154 0.7496 0.8425 0.4692 0.3916 0.5638 0.1778 0.1327 0.5019 0.0487 0.4290 0.8929 0.6245 0.4104 0.7341 0.3470 0.3626 0.8302 0.8068 0.7070 0.0275 0.6869 0.6103 0.1568 0.5963 0.2501 0.2228 0.0602 0.2342 0.6254 0.1872 0.5707 0.0979 0.9501 0.8040 0.8105 0.7812 0.6538 0.1806 0.2291 0.4436 0.8528 0.0326 0.2603 0.2303 0.8388 0.5692 0.4614 0.8849 0.8150 0.6281 0.6943 0.1709 0.9649 0.8721 0.1604 0.1331 0.0226 0.2427 0.6618 0.8555 0.6393 0.1930 0.3993 0.6589 0.9762 0.6322 0.4481 0.0635 0.6196 0.2524 0.4977 0.2948 0.2574 0.6219 0.6980 0.8765 0.6571 0.7840 0.1278 0.0258 0.6337 0.3072 0.8781 0.1614 0.1924 0.1687 0.9065 0.8827 0.7441 0.2938 0.1716 0.6515 0.7968 0.2935 0.4464 0.3992 0.2981 0.9079 0.4901 B(:,:,6) = 0.1722 0.6192 0.5942 0.5151 0.6236 0.5691 0.9023 0.6547 0.3539 0.3941 0.3814 0.9429 0.5296 0.4373 0.9919 0.2819 0.6719 0.7906 0.8038 0.8556 0.9972 0.8950 0.4665 0.9133 0.2350 0.4796 0.2747 0.3307 0.8008 0.8741 0.1564 0.3723 0.7224 0.4954 0.9637 0.8393 0.1638 0.9728 0.3924 0.7431 0.1753 0.8418 0.4405 0.4148 0.6882 0.1428 0.9709 0.5888 0.3210 0.3876 0.7682 0.7876 0.8282 0.9847 0.9169 0.9474 0.1411 0.3598 0.4099 0.4655 0.5363 0.4737 0.1615 0.8235 0.9300 0.1935 0.5289 0.9153 0.7849 0.0762 0.5086 0.5907 0.5583 0.9891 0.2438 0.2004 0.0109 0.9562 0.3445 0.0521 0.2347 0.8796 0.9414 0.8447 0.5314 0.3107 0.7096 0.7488 0.0315 0.5738 0.7679 0.9610 0.2990 0.1102 0.5484 0.2975 0.5371 0.6627 0.6368 0.9234 B(:,:,7) = 0.6113 0.5852 0.8326 0.9645 0.9135 0.3175 0.6800 0.0663 0.1830 0.6678 0.5831 0.0356 0.3231 0.9767 0.0205 0.7895 0.2647 0.9865 0.9170 0.4260 0.7466 0.3117 0.2596 0.8614 0.7079 0.2524 0.9423 0.1407 0.4276 0.1740 0.4678 0.5675 0.1605 0.4474 0.8176 0.2176 0.1463 0.5625 0.9963 0.0592 0.5475 0.0713 0.7678 0.1458 0.6167 0.5289 0.8400 0.6617 0.1591 0.7750 0.2533 0.9626 0.8517 0.3954 0.9484 0.1215 0.0540 0.1048 0.2503 0.2313 0.9772 0.8835 0.5006 0.4543 0.8295 0.1151 0.2214 0.6613 0.7207 0.6775 0.1957 0.2955 0.8227 0.8646 0.1249 0.0502 0.2912 0.6343 0.0253 0.5178 0.1090 0.0187 0.9976 0.5448 0.2619 0.7955 0.8842 0.7015 0.9026 0.1159 0.2116 0.0183 0.3514 0.5087 0.7695 0.6439 0.8711 0.4755 0.2899 0.2983 B(:,:,8) = 0.6275 0.5690 0.3370 0.7589 0.5853 0.8505 0.2033 0.5250 0.3991 0.3142 0.4815 0.1839 0.8354 0.0669 0.0220 0.5982 0.5680 0.1567 0.2849 0.0725 0.2816 0.9391 0.1367 0.3388 0.0805 0.3223 0.7528 0.6802 0.7383 0.7544 0.9823 0.1902 0.1142 0.3458 0.6411 0.8845 0.7842 0.0416 0.3728 0.7668 0.5259 0.0307 0.0460 0.5357 0.4280 0.5200 0.4141 0.5179 0.9224 0.4470 0.2917 0.2459 0.3294 0.1049 0.2701 0.7356 0.7351 0.9807 0.4737 0.4692 0.4880 0.1398 0.6711 0.2151 0.8939 0.3240 0.1551 0.0931 0.4730 0.2536 0.0586 0.2608 0.9124 0.9706 0.9623 0.0339 0.3442 0.6957 0.5825 0.8688 0.4561 0.1063 0.0590 0.7035 0.6844 0.9077 0.3990 0.8750 0.0858 0.5531 0.7557 0.2167 0.8064 0.1942 0.5241 0.3545 0.4979 0.5633 0.9469 0.0394 B(:,:,9) = 0.2159 0.8930 0.8551 0.2916 0.2305 0.3277 0.3606 0.4912 0.1550 0.8940 0.2173 0.5272 0.4841 0.3140 0.2016 0.0419 0.7581 0.4611 0.6997 0.1621 0.8368 0.4181 0.4840 0.7356 0.7452 0.9667 0.1255 0.8021 0.0109 0.3835 0.8046 0.4887 0.9626 0.8643 0.8898 0.6984 0.2156 0.5890 0.0395 0.1571 0.0705 0.8352 0.7911 0.3127 0.5908 0.6634 0.8306 0.1917 0.5612 0.2263 0.4467 0.8067 0.3753 0.0136 0.8583 0.8200 0.9120 0.5841 0.4611 0.8999 0.2157 0.3274 0.4976 0.5291 0.9733 0.8377 0.3990 0.2832 0.1672 0.5292 0.9258 0.2930 0.0657 0.9581 0.3767 0.2297 0.9392 0.0710 0.3623 0.2587 0.9736 0.1675 0.3481 0.8467 0.2171 0.3149 0.0108 0.0633 0.4782 0.7948 0.1590 0.0320 0.0187 0.4724 0.8563 0.0003 0.6477 0.5296 0.3185 0.3071 B(:,:,10) = 0.6499 0.7128 0.7261 0.1176 0.8186 0.7578 0.8773 0.5060 0.8871 0.6039 0.3710 0.6039 0.2477 0.6402 0.7854 0.0957 0.7273 0.7628 0.3588 0.0055 0.2590 0.9789 0.0451 0.2731 0.4919 0.7113 0.6329 0.2551 0.8794 0.5192 0.1563 0.0190 0.2742 0.5443 0.2747 0.2688 0.1855 0.3005 0.0439 0.4595 0.4769 0.6453 0.1334 0.9404 0.7767 0.8207 0.9356 0.1566 0.1645 0.6655 0.8391 0.7454 0.5119 0.9009 0.9212 0.6277 0.1183 0.0450 0.6783 0.7062 0.1773 0.8875 0.2276 0.4254 0.4673 0.7150 0.5396 0.1002 0.2584 0.7450 0.3046 0.1318 0.0867 0.6020 0.2988 0.0805 ...

6   Pass
A = repmat(13,89,17); assert(isequal(your_fcn_name(A),repmat(0,89,17))) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

7   Pass
A= magic(5); B =A; B(3,3) = 0 assert(isequal(your_fcn_name(A),B)) filetext = fileread('your_fcn_name.m'); assert(isempty(strfind(filetext, 'for')),'for command is forbidden') assert(isempty(strfind(filetext, 'while')),'while command is forbidden') assert(isempty(strfind(filetext, 'find')),'find command is forbidden') assert(isempty(strfind(filetext, 'ind2sub')),'ind2sub command is forbidden')

B = 17 24 1 8 15 23 5 7 14 16 4 6 0 20 22 10 12 19 21 3 11 18 25 2 9 B = 17 24 1 8 15 23 5 7 14 16 4 6 0 20 22 10 12 19 21 3 11 18 25 2 9

8   Pass
A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

B = 13.3000