Cody

Solution 1985343

Submitted on 22 Oct 2019 by asa czylabson
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')

A = 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')

A = 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')

A = []

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')

A = 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')

A(:,:,1) = 0.0256 0.7829 0.2811 0.0211 0.3830 0.7202 0.2340 0.2945 0.8777 0.7327 0.9912 0.3486 0.4345 0.6162 0.4612 0.2220 0.3483 0.6910 0.6193 0.9768 0.1873 0.0342 0.5856 0 0.9794 0.6134 0.5493 0.4770 0.0255 0.3641 0.2988 0.2311 0.5870 0.2899 0.9697 0.3964 0.6524 0.4703 0.9569 0.9293 0.0519 0.1147 0.1408 0.9752 0.3407 0.7582 0.6887 0.6671 0.4850 0.0620 0.1993 0.3140 0.7154 0.0140 0.1357 0.8625 0.3567 0.5958 0.4162 0.3820 0.7871 0.2529 0.5817 0.2363 0.2486 0.6186 0.6179 0.4201 0.0567 0.9566 0.8254 0.6109 0.8548 0.0798 0.1279 0.4487 0.1732 0.6117 0.9041 0.0272 0.5695 0.5499 0.3802 0.7731 0.6832 0.7280 0.4885 0.2913 0.0983 0.7155 0.9583 0.1975 0.8455 0.6961 0.8472 0.7188 0.3807 0.0429 0.3203 0.1057 A(:,:,2) = 0.9365 0 0.8658 0.3972 0.8024 0.2682 0.5417 0.8220 0.3594 0.0526 0.4472 0.3372 0.2407 0.4461 0.7139 0.3355 0.3884 0.7848 0.9270 0.1184 0.6278 0.7524 0.8606 0.4272 0.4942 0.1818 0.4909 0.3998 0.6707 0.2999 0.5157 0.0324 0.9488 0.4303 0.5871 0.6998 0.4550 0.7080 0.3127 0.8150 0.5734 0.4418 0.3793 0.8081 0.8115 0.4012 0.6152 0.5337 0.6528 0.5366 0.7414 0.7426 0.1911 0.0462 0.8360 0.7738 0.4087 0.6479 0.0765 0.8617 0.4676 0.1740 0.3393 0.5933 0.6011 0.0286 0.1442 0.1722 0.3015 0.2125 0.3732 0.5104 0.3986 0.8002 0.0037 0.8298 0.2080 0.6105 0.8115 0.6755 0.6347 0.8764 0.4601 0.8065 0.4500 0.0858 0.7510 0.6198 0.0409 0.3830 0.2630 0.7218 0.3712 0.2706 0.3362 0.7836 0.7387 0.6707 0.2113 0.0335 A(:,:,3) = 0.7107 0.4358 0.8708 0.7731 0.9035 0.9717 0.7102 0.3626 0.8766 0.4298 0.0038 0.1904 0.2310 0.9665 0.0471 0.2792 0.0938 0.2064 0.4396 0.1749 0.9921 0.2553 0.4713 0.3102 0.7275 0.7484 0.1981 0.8036 0.8830 0.3665 0.8055 0.9417 0.8342 0.5195 0.7997 0.1239 0.1221 0.1384 0.9244 0.5375 0.0075 0.3861 0.6411 0.0753 0.4153 0 0.3869 0.1012 0.7091 0.8039 0.8616 0.0220 0.7158 0.1015 0.2041 0.6483 0.2198 0.6664 0.2979 0.7921 0.7152 0.5581 0.8495 0.3142 0.6968 0.3684 0.8974 0.7006 0.2677 0.3023 0.1287 0.4343 0.6050 0.2804 0.0036 0.8250 0.7072 0.1388 0.4631 0.6944 0.6440 0.8681 0.5939 0.1410 0.3805 0.6913 0.3998 0.9299 0.8935 0.8244 0.3141 0.2965 0.4048 0.1353 0.7794 0.1471 0.1903 0.8702 0.3169 0.5062 A(:,:,4) = 0.1917 0.4780 0.6469 0.7686 0.1021 0.2262 0.0335 0.1514 0.6562 0.6313 0.1390 0.9710 0.8920 0.7388 0.4383 0.9798 0.7170 0.7497 0.9514 0.8535 0.9011 0.2245 0.6460 0.0470 0.8864 0.5921 0.0382 0.3306 0.3950 0.5668 0.9645 0.9483 0.4738 0.4699 0.6895 0.7350 0.4458 0.6099 0.2821 0.1712 0.0023 0.7201 0.4371 0.6891 0.1164 0.3214 0.6992 0.0825 0.7101 0.2312 0.8259 0.2640 0.9816 0.9010 0.9720 0.1975 0.1814 0.6497 0.5103 0.8267 0.2685 0.1382 0.8602 0.6978 0.9210 0.0661 0.3751 0.8515 0.1509 0.8053 0.8318 0.4951 0.5843 0.3882 0.8469 0.5118 0.5908 0.4427 0.2279 0.8411 0.0460 0.7669 0.7779 0.0909 0.8577 0.2441 0.4961 0.0757 0.7811 0.9826 0.8635 0.2557 0.1939 0.8009 0.6405 0.6067 0.1463 0.1467 0.7794 0.7007 A(:,:,5) = 0.8035 0.4840 0.9051 0.4969 0.7824 0.6875 0.9457 0.1358 0.0141 0.5419 0.5069 0.6044 0.3311 0.4176 0.4967 0.6497 0.3183 0.6026 0.2608 0.0274 0.1577 0.3778 0.0026 0.1860 0.1515 0.3425 0.6010 0.2075 0.8376 0.1697 0.0542 0.8616 0.2350 0.7508 0.4740 0.5087 0.8384 0.3077 0.0400 0.4314 0.9597 0.4508 0.9946 0.6566 0.1438 0.0307 0.7549 0.0288 0.1652 0.6183 0.9213 0.8326 0.2512 0.0793 0.2299 0.3729 0.7685 0.3901 0.2592 0.4120 0.8435 0.7653 0.5068 0.2583 0.9851 0.7359 0.1027 0.2986 0.1825 0.9719 0.7084 0.6226 0.7388 0.3155 0.5323 0.2573 0.1167 0.2739 0.3718 0.7991 0.5775 0.1044 0.2230 0.3079 0.7777 0.7840 0.0829 0.0270 0.6851 0.8367 0.9891 0.8894 0.5448 0.3983 0.1794 0.8462 0.6272 0.6547 0.9690 0.9433 A(:,:,6) = 0.7727 0.4282 0.4997 0.9121 0.9506 0.9549 0.9479 0.7661 0.0588 0.3139 0.8591 0.7759 0.2815 0.9867 0.5081 0.3534 0.7698 0.3618 0.1616 0.2814 0.8339 0.6401 0.9704 0.6355 0.4424 0.5825 0.9627 0.5650 0.1549 0.0758 0.6432 0.7403 0.8847 0.0354 0.8786 0.9980 0.3074 0.2635 0.3322 0.5184 0.1153 0.7870 0.6502 0.4510 0.0123 0.0418 0.4061 0.2347 0.9200 0.0996 0.9452 0.5316 0.2977 0.7746 0.7510 0.8850 0.1795 0.7089 0.4996 0.1746 0.2848 0.1645 0.7559 0.8082 0.7852 0.6993 0.0549 0.7348 0.0826 0.2863 0.3494 0.4830 0.7840 0.8456 0.7697 0.2375 0.4713 0.2055 0.8629 0.7063 0.3565 0.0395 0.4401 0.8116 0.0865 0.0416 0.4646 0.0581 0.0228 0.2732 0.2956 0.7521 0.6931 0.4171 0.9341 0.9797 0.2088 0.1063 0.9214 0.6798 A(:,:,7) = 0.8662 0.0830 0.2792 0.3503 0.8656 0.5800 0.1371 0.2229 0.2865 0.2127 0.5947 0.6241 0.3189 0.1232 0.2712 0.9035 0.4410 0.5305 0.9690 0.8487 0.3187 0.0230 0.1211 0.3281 0.2383 0.3607 0.2349 0.3612 0.7251 0.0166 0.9353 0.6834 0.3261 0.0180 0.9760 0.2359 0.9562 0.4681 0.6538 0.4781 0.0007 0.2654 0.1094 0.4614 0.9901 0.1297 0.0908 0.4076 0.7713 0.1163 0.7231 0.4311 0.0046 0.9723 0.1161 0.8384 0.8492 0.2723 0.9415 0.2928 0.4819 0.5849 0.6626 0.0592 0.8986 0.7770 0.2216 0.6165 0.5604 0.2007 0.6726 0.2189 0.4863 0.1173 0.4091 0.7522 0.0653 0.7798 0.2530 0.4864 0.4451 0.0818 0.0019 0.8312 0.9177 0.5824 0.8131 0.9490 0.3202 0.3968 0.1223 0.1242 0.6075 0.8092 0.2554 0.8431 0.6478 0.6844 0.4920 0.7859 A(:,:,8) = 0.7442 0.9259 0.5674 0.1422 0.1386 0.7071 0.9182 0.2105 0.8371 0.9477 0.4223 0.4953 0.2435 0.7378 0.7976 0.1540 0.3097 0.3305 0.7545 0.7975 0.6041 0.3077 0.3223 0.6706 0.8256 0.3699 0.1505 0.7185 0.7235 0.7999 0.9638 0.8192 0.6434 0.3973 0.0636 0.6060 0.8747 0.6283 0.4822 0.9063 0.7754 0.3128 0.1493 0.8801 0.3515 0.6301 0.9744 0.8152 0.7351 0.5242 0.8951 0.3954 0.3638 0.8181 0.0192 0.9647 0.9784 0.0823 0.6457 0.5985 0.5757 0.9663 0.0643 0.3176 0.8359 0.8601 0.5818 0.7506 0.1692 0.2416 0.4429 0.6210 0.9314 0.0002 0.2565 0.8137 0.9909 0.4785 0.2343 0.5127 0.2142 0.5388 0.4669 0.4011 0.4587 0.4053 0.8383 0.2809 0.6722 0.3507 0.7361 0.6938 0.4756 0.9915 0.3747 0.9258 0.6864 0.4493 0.2861 0.5067 A(:,:,9) = 0.0800 0.9444 0.5984 0.8853 0.6710 0.3546 0.3406 0.6809 0.7979 0.1346 0.8254 0.0047 0.9977 0.7375 0.9073 0.5547 0.9339 0.9607 0.8674 0.5865 0.0914 0.6216 0.2261 0.3174 0.2716 0.3994 0.9656 0.5541 0.5708 0.9764 0.7417 0.5905 0.0689 0.9399 0.8629 0.5440 0.0084 0.0780 0.2204 0.8341 0.7410 0.8198 0.6044 0.4249 0.8744 0.1808 0.8295 0.2126 0.7162 0.8640 0.1506 0.8620 0.7937 0.5355 0.4450 0.8904 0.0401 0.7988 0.9596 0.6839 0.9741 0.6022 0.4787 0.3869 0.8407 0.3289 0.5485 0.0701 0.0913 0.9504 0.5874 0.8798 0.8815 0.9580 0.6875 0.6904 0.9723 0.9071 0.2425 0.1042 0.1930 0.9985 0.4312 0.9632 0.9805 0.0562 0.0649 0.4815 0.8929 0.3309 0.4794 0.7404 0.1737 0.0586 0.4891 0.0387 0.2415 0.6319 0.4971 0.4903 A(:,:,10) = 0.2314 0.8935 0.6426 0.3129 0.5395 0.7306 0.6626 0.3205 0.0190 0.4844 0.7669 0.3327 0.9279 0.7166 0.1813 0.7868 0.4067 0.8765 0.9895 0.7003 0.0456 0.7140 0.2057 0.2521 0.1725 0.7165 0.9352 0.9990 0.0292 0.4529 0.5997 0.5339 0.6957 0.2513 0.8823 0.9219 0.4131 0.9793 0.4676 0.2860 0.8242 0.1287 0.3883 0.6042 0.1847 0.4200 0.4860 0.3059 0.4520 0.4760 0.1150 0.9742 0.1161 0.2206 0.8990 0.9902 0.4761 0.9716 0.8341 0.1928 0.8702 0.3090 0.9651 0.7168 0.0600 0.8953 0.7787 0.9503 0.2810 0.8689 0.4865 0.1139 0.7084 0.1644 0.8102 0.8984 ...

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')

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

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 A = 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))

A = 13.3000