Cody

Solution 1973841

Submitted on 13 Oct 2019 by Tung Nguyen
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.3396 0.6199 0.5779 0.5779 0.4561 0.8338 0.2117 0.2829 0.4449 0.2795 0.9598 0.8167 0.3043 0.2065 0.6328 0.8131 0.9429 0.5041 0.1544 0.9108 0.9847 0.3552 0.6388 0 0.1226 0.9886 0.8253 0.0799 0.6016 0.7744 0.0234 0.6029 0.5221 0.0582 0.9816 0.4348 0.3626 0.4576 0.3561 0.2342 0.6192 0.5619 0.5508 0.0051 0.1873 0.3117 0.8203 0.6402 0.7790 0.5082 0.1563 0.4980 0.0985 0.1475 0.7236 0.4102 0.8186 0.1413 0.5464 0.4177 0.4546 0.0172 0.0984 0.6776 0.9652 0.7297 0.6335 0.6694 0.9283 0.2536 0.3381 0.8943 0.3953 0.4350 0.1209 0.8872 0.0371 0.8398 0.1075 0.8747 0.1865 0.7967 0.8701 0.1178 0.4475 0.1668 0.9967 0.5524 0.6919 0.7918 0.4684 0.0144 0.5667 0.5372 0.7241 0.6175 0.7058 0.5176 0.6588 0.4861 B(:,:,2) = 0.0468 0 0.1978 0.1747 0.4393 0.7034 0.1790 0.8879 0.5897 0.4568 0.2636 0.8539 0.5519 0.0716 0.4214 0.8739 0.4971 0.7732 0.4098 0.2267 0.9981 0.8334 0.1492 0.7114 0.1766 0.9789 0.7980 0.3867 0.5599 0.4440 0.3105 0.0444 0.2945 0.0772 0.5795 0.8906 0.2602 0.8634 0.3662 0.2157 0.1770 0.2914 0.8703 0.1017 0.1341 0.8938 0.9887 0.7886 0.8653 0.3390 0.9754 0.1571 0.6861 0.0135 0.8188 0.6828 0.2664 0.3715 0.2869 0.7390 0.1447 0.8323 0.6221 0.2702 0.7303 0.1296 0.8337 0.8563 0.7432 0.6891 0.4093 0.4899 0.3568 0.5782 0.2496 0.8439 0.6763 0.5773 0.4029 0.3682 0.0539 0.0162 0.4013 0.5982 0.2224 0.2011 0.4424 0.3332 0.0884 0.0345 0.1270 0.7637 0.2226 0.9230 0.6969 0.6617 0.7364 0.7567 0.6735 0.0526 B(:,:,3) = 0.3245 0.5927 0.0005 0.4645 0.2455 0.4088 0.2658 0.5839 0.7795 0.2519 0.0937 0.0546 0.4908 0.1720 0.3761 0.7543 0.7899 0.1164 0.2301 0.8908 0.7763 0.0052 0.1050 0.0198 0.1039 0.4082 0.2482 0.8846 0.8615 0.8513 0.8449 0.4545 0.9730 0.5951 0.6901 0.6180 0.5096 0.4460 0.7436 0.9727 0.5670 0.8587 0.4616 0.5860 0.5975 0 0.5980 0.0305 0.8442 0.5985 0.5566 0.1055 0.8417 0.7048 0.9806 0.9350 0.2261 0.3859 0.2659 0.7270 0.8020 0.5851 0.6903 0.2509 0.5414 0.1210 0.0320 0.0156 0.1738 0.3851 0.1685 0.3307 0.4693 0.5124 0.0501 0.3004 0.7546 0.7437 0.8856 0.8357 0.5826 0.3362 0.1155 0.8732 0.1370 0.0913 0.1145 0.1121 0.1222 0.5789 0.2070 0.1786 0.5903 0.9189 0.2716 0.6684 0.4654 0.5351 0.3466 0.7892 B(:,:,4) = 0.6656 0.3292 0.8087 0.8107 0.4838 0.1890 0.6425 0.6576 0.6431 0.4578 0.3488 0.9757 0.6047 0.4105 0.8430 0.7025 0.5265 0.2830 0.3243 0.3518 0.8960 0.5938 0.8315 0.9065 0.9050 0.4591 0.2841 0.3633 0.5454 0.3751 0.5929 0.7195 0.0843 0.5347 0.4185 0.7904 0.3729 0.3229 0.5942 0.8102 0.1960 0.1417 0.6989 0.9949 0.9647 0.8908 0.7498 0.5800 0.7623 0.7745 0.7158 0.5531 0.7339 0.9345 0.4870 0.5566 0.7017 0.6365 0.9054 0.2303 0.3835 0.6637 0.9489 0.6667 0.6859 0.5010 0.9875 0.7700 0.6293 0.0322 0.1310 0.5984 0.2508 0.1026 0.5207 0.9977 0.1310 0.5208 0.1701 0.0465 0.7520 0.3100 0.4632 0.5414 0.7065 0.8550 0.2427 0.2094 0.7758 0.1279 0.5322 0.7771 0.0857 0.2049 0.2065 0.7878 0.4394 0.3911 0.0674 0.8007 B(:,:,5) = 0.1419 0.0255 0.9814 0.0975 0.9313 0.1475 0.1310 0.7055 0.4524 0.8804 0.9770 0.0787 0.2335 0.2495 0.7212 0.2942 0.5216 0.4103 0.5552 0.4657 0.0488 0.2883 0.0099 0.8761 0.5784 0.7553 0.7961 0.1556 0.9924 0.8188 0.3950 0.4979 0.8927 0.3797 0.9421 0.6115 0.4045 0.7001 0.7461 0.9818 0.4211 0.1426 0.9930 0.0996 0.8333 0.7763 0.3132 0.7487 0.5790 0.3332 0.8341 0.7708 0.1877 0.0203 0.3900 0.0716 0.3345 0.4622 0.7890 0.6264 0.7871 0.0718 0.0923 0.3820 0.4365 0.4192 0.3568 0.8831 0.8356 0.0706 0.3192 0.5574 0.6573 0.3936 0.3516 0.2665 0.8639 0.3207 0.6833 0.0009 0.9111 0.5947 0.7397 0.1063 0.2941 0.4340 0.6778 0.8165 0.0545 0.7510 0.7779 0.5681 0.5273 0.3750 0.1448 0.2081 0.3949 0.9556 0.6350 0.1571 B(:,:,6) = 0.7755 0.3429 0.9488 0.4987 0.0217 0.9529 0.6804 0.8274 0.8408 0.3170 0.9117 0.4153 0.1907 0.8594 0.4679 0.0897 0.0713 0.7165 0.8349 0.9890 0.9546 0.1966 0.2883 0.8772 0.9877 0.3101 0.9736 0.2469 0.9741 0.3052 0.9268 0.6904 0.3159 0.9528 0.3940 0.1517 0.7615 0.8021 0.1542 0.1498 0.3349 0.8179 0.0720 0.6536 0.4217 0.8663 0.8692 0.6730 0.7232 0.2518 0.1319 0.6391 0.0644 0.2836 0.8573 0.9265 0.2439 0.2426 0.6643 0.9141 0.9681 0.5354 0.4709 0.5002 0.6156 0.9359 0.1797 0.2516 0.7940 0.1643 0.2210 0.8878 0.5771 0.3818 0.9533 0.0565 0.7685 0.1104 0.6393 0.7704 0.5577 0.7716 0.7271 0.8115 0.5602 0.5136 0.8699 0.6587 0.7193 0.5009 0.2506 0.1079 0.1149 0.8665 0.1699 0.3232 0.7201 0.2845 0.1270 0.8814 B(:,:,7) = 0.6045 0.6573 0.0986 0.5752 0.8388 0.9403 0.1244 0.4205 0.0109 0.6475 0.9497 0.4422 0.9189 0.7893 0.8711 0.8971 0.8078 0.6536 0.4785 0.5348 0.4991 0.3454 0.0743 0.2778 0.7496 0.7665 0.8723 0.6876 0.7640 0.7703 0.5604 0.5712 0.1710 0.8273 0.3156 0.0144 0.0281 0.3025 0.7560 0.6214 0.0200 0.0050 0.9818 0.7394 0.2285 0.3631 0.3979 0.5160 0.4678 0.8933 0.9505 0.4039 0.4537 0.2842 0.1823 0.2419 0.6470 0.4586 0.6960 0.3924 0.4596 0.3284 0.7130 0.2822 0.1450 0.7350 0.2936 0.9076 0.4300 0.7993 0.3449 0.0077 0.5891 0.9222 0.7221 0.5797 0.9473 0.0149 0.7164 0.0380 0.1041 0.4817 0.5678 0.2842 0.8896 0.9933 0.2822 0.4585 0.2991 0.6886 0.9273 0.5066 0.4186 0.7462 0.3071 0.7418 0.2615 0.1043 0.8184 0.6413 B(:,:,8) = 0.6719 0.4490 0.0695 0.1509 0.8474 0.0633 0.4984 0.3075 0.0499 0.4930 0.1912 0.8578 0.2328 0.9594 0.5720 0.2461 0.6274 0.7394 0.7495 0.6844 0.7678 0.4845 0.5010 0.7152 0.9119 0.3357 0.6036 0.4356 0.6706 0.7279 0.9788 0.7190 0.7679 0.2861 0.8791 0.6359 0.3730 0.9094 0.0391 0.6152 0.6210 0.4199 0.4777 0.7067 0.8040 0.9535 0.0104 0.6067 0.3290 0.2173 0.0881 0.0254 0.7768 0.6429 0.7636 0.1215 0.5574 0.9990 0.1346 0.2907 0.4355 0.9754 0.7702 0.1983 0.4332 0.2296 0.4257 0.5416 0.3831 0.2851 0.7301 0.6742 0.1428 0.9188 0.3705 0.4709 0.1298 0.0814 0.0613 0.6715 0.6029 0.4364 0.5631 0.0860 0.5932 0.9165 0.2156 0.5380 0.6563 0.2422 0.4295 0.8408 0.7587 0.0720 0.2975 0.1335 0.7424 0.4639 0.5707 0.4659 B(:,:,9) = 0.7721 0.0251 0.7781 0.8318 0.6125 0.3090 0.1019 0.1038 0.6665 0.9653 0.2433 0.7359 0.5151 0.7562 0.4645 0.2918 0.3148 0.8085 0.2386 0.3934 0.3386 0.8113 0.1794 0.9451 0.4003 0.1659 0.0819 0.8968 0.4277 0.0272 0.9649 0.4233 0.9718 0.6849 0.0046 0.3296 0.2315 0.4007 0.1852 0.5383 0.2042 0.0071 0.8483 0.7635 0.3826 0.6969 0.7098 0.5642 0.5133 0.9044 0.8803 0.9336 0.1692 0.0882 0.2638 0.3154 0.3448 0.8203 0.3800 0.6056 0.6640 0.0155 0.6912 0.9670 0.3429 0.9206 0.3782 0.9534 0.8857 0.8005 0.8998 0.0285 0.1100 0.0146 0.3365 0.3182 0.9393 0.9302 0.6529 0.1101 0.5868 0.1649 0.7950 0.7241 0.9218 0.1455 0.2300 0.1695 0.2720 0.7282 0.9354 0.0723 0.1066 0.6695 0.3644 0.2089 0.2815 0.8853 0.9187 0.9306 B(:,:,10) = 0.6812 0.6380 0.1422 0.3673 0.7386 0.4791 0.5364 0.9124 0.2781 0.9147 0.2665 0.5778 0.2113 0.2544 0.0517 0.1416 0.0080 0.7316 0.3856 0.2678 0.8835 0.4392 0.3595 0.4596 0.5192 0.8192 0.8093 0.2673 0.5720 0.7481 0.8466 0.6256 0.6857 0.8816 0.5274 0.2090 0.1765 0.7765 0.2821 0.0939 0.0479 0.6918 0.6368 0.9702 0.0650 0.1334 0.7111 0.1843 0.0451 0.7209 0.6217 0.7600 0.3058 0.9853 0.7516 0.5708 0.1007 0.4155 0.1279 0.8714 0.4028 0.6287 0.6727 0.1177 0.6342 0.7970 0.6206 0.4801 0.9319 0.2863 0.7362 0.8781 0.4625 0.3834 0.1135 0.3604 ...

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