Cody

Solution 1585376

Submitted on 17 Jul 2018 by Srishti Saha
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 ans = 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 ans = 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 = [] ans = []

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 ans = 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.5905 0.3945 0.4580 0.5175 0.7815 0.9847 0.5609 0.7285 0.4075 0.1337 0.5781 0.0937 0.1865 0.3330 0.8576 0.1000 0.3148 0.9470 0.0746 0.8369 0.3996 0.6286 0.3029 0 0.1341 0.6314 0.0824 0.5730 0.7491 0.2463 0.6047 0.2669 0.7562 0.0413 0.7314 0.0711 0.9215 0.7240 0.4315 0.9857 0.6058 0.2118 0.1547 0.3307 0.1783 0.6633 0.7896 0.3043 0.7249 0.1761 0.9549 0.4758 0.9064 0.9042 0.7289 0.6673 0.3950 0.0113 0.3989 0.3983 0.0954 0.3776 0.1808 0.9213 0.3845 0.6728 0.8659 0.0781 0.6183 0.6602 0.0318 0.0707 0.1044 0.0490 0.1819 0.7099 0.0867 0.5952 0.2542 0.9923 0.4688 0.5651 0.0946 0.4247 0.0996 0.8459 0.7727 0.6355 0.0179 0.3650 0.9266 0.5465 0.6653 0.6484 0.5870 0.3008 0.6269 0.0053 0.3251 0.1193 A(:,:,2) = 0.3547 0 0.4863 0.8715 0.5570 0.1980 0.4194 0.1682 0.5765 0.3298 0.0974 0.9470 0.0531 0.4822 0.1852 0.2511 0.7777 0.5880 0.6945 0.0617 0.6662 0.1290 0.2524 0.3045 0.6054 0.6560 0.4615 0.6733 0.2757 0.5970 0.7881 0.9476 0.5724 0.2102 0.9691 0.3235 0.4664 0.9775 0.8515 0.1849 0.2363 0.7966 0.5536 0.9930 0.8480 0.3696 0.1625 0.1267 0.3887 0.1892 0.0738 0.5858 0.1751 0.0682 0.3569 0.9229 0.9241 0.5042 0.4119 0.5209 0.6837 0.6160 0.8263 0.7781 0.1564 0.5510 0.0930 0.0379 0.7072 0.1853 0.8210 0.0403 0.1492 0.6843 0.4752 0.2579 0.8378 0.6310 0.9052 0.6295 0.3434 0.6776 0.4461 0.5442 0.6129 0.5336 0.0833 0.2137 0.8228 0.4697 0.5592 0.1602 0.3370 0.9332 0.6867 0.7590 0.1247 0.5566 0.4758 0.2185 A(:,:,3) = 0.9830 0.1919 0.7030 0.9062 0.5584 0.4757 0.2374 0.2063 0.9677 0.7903 0.5218 0.6195 0.0706 0.3497 0.6222 0.9490 0.7728 0.1491 0.1473 0.7032 0.5048 0.5950 0.6017 0.1910 0.4189 0.4371 0.5755 0.3335 0.9378 0.7048 0.2511 0.8632 0.0938 0.9135 0.5270 0.9514 0.0091 0.4096 0.7251 0.5260 0.6187 0.4865 0.9543 0.4554 0.6337 0 0.3417 0.8719 0.1200 0.8902 0.8226 0.9780 0.7698 0.2838 0.7806 0.5908 0.0769 0.5553 0.9159 0.9281 0.3174 0.9445 0.3950 0.6847 0.7208 0.9016 0.6481 0.7807 0.9542 0.7880 0.5812 0.6088 0.6339 0.8668 0.4726 0.6933 0.3943 0.5949 0.4081 0.0920 0.6643 0.7703 0.2043 0.9858 0.2137 0.9655 0.0312 0.0065 0.1072 0.2064 0.3209 0.4253 0.7967 0.2117 0.3893 0.3720 0.7784 0.0077 0.5471 0.8846 A(:,:,4) = 0.1470 0.7013 0.8513 0.3360 0.6696 0.8674 0.4586 0.6694 0.3353 0.8442 0.4941 0.0364 0.1787 0.7269 0.6749 0.9989 0.5336 0.0136 0.7721 0.1645 0.8347 0.5123 0.3442 0.0831 0.9929 0.1954 0.0329 0.9664 0.2491 0.6075 0.9470 0.5732 0.7393 0.2518 0.5845 0.1841 0.5027 0.5452 0.8668 0.4278 0.6928 0.2209 0.9905 0.7209 0.2096 0.8005 0.8110 0.9478 0.6322 0.6765 0.4329 0.7000 0.8130 0.4517 0.7429 0.6357 0.7340 0.7079 0.7752 0.5880 0.5046 0.1397 0.8875 0.0258 0.8968 0.8473 0.9697 0.0189 0.4025 0.4776 0.9419 0.8687 0.1928 0.0133 0.3441 0.6434 0.2180 0.2237 0.9493 0.5573 0.2337 0.0753 0.2186 0.7847 0.0669 0.0316 0.2652 0.5206 0.3443 0.9324 0.8420 0.8361 0.8954 0.7756 0.5593 0.5100 0.1479 0.4545 0.5726 0.4800 A(:,:,5) = 0.0005 0.3200 0.2071 0.6810 0.0300 0.2795 0.2837 0.0573 0.6071 0.9750 0.3453 0.7122 0.7854 0.2817 0.4132 0.3542 0.5217 0.6182 0.1930 0.8520 0.0598 0.0698 0.4563 0.0489 0.4938 0.6728 0.1092 0.5425 0.4916 0.6351 0.2009 0.7987 0.2776 0.8722 0.4710 0.1577 0.1059 0.8375 0.4627 0.9831 0.2077 0.1893 0.5691 0.6753 0.2942 0.7723 0.9042 0.8618 0.6567 0.5523 0.2300 0.6253 0.4699 0.2378 0.9496 0.1264 0.4561 0.1010 0.7876 0.5173 0.5990 0.6352 0.1719 0.4180 0.8349 0.1556 0.4157 0.6216 0.0868 0.7270 0.0477 0.9969 0.7212 0.4982 0.0616 0.5785 0.2518 0.4556 0.7163 0.9301 0.0461 0.7944 0.5622 0.3370 0.4255 0.0309 0.9756 0.8615 0.3625 0.9896 0.1856 0.4668 0.3910 0.4258 0.8633 0.4243 0.7442 0.6299 0.4310 0.5460 A(:,:,6) = 0.5080 0.3156 0.4505 0.6347 0.1960 0.9537 0.1364 0.2082 0.2938 0.4765 0.8317 0.5708 0.5712 0.1661 0.3525 0.9951 0.6115 0.7240 0.6950 0.9952 0.9105 0.1678 0.2233 0.0906 0.1364 0.2729 0.1162 0.8635 0.7526 0.7276 0.7223 0.3549 0.5818 0.0976 0.4967 0.7224 0.2923 0.4110 0.0748 0.2112 0.0982 0.0735 0.0466 0.5037 0.1507 0.0193 0.4339 0.8100 0.6390 0.7784 0.9812 0.6951 0.5232 0.0929 0.7377 0.1593 0.8989 0.7414 0.4868 0.1093 0.3170 0.0550 0.1770 0.0240 0.1834 0.2609 0.4992 0.4721 0.3289 0.6706 0.6098 0.1242 0.3501 0.8254 0.2826 0.4501 0.4889 0.0232 0.7910 0.9254 0.9089 0.9401 0.4759 0.0065 0.6660 0.5583 0.0383 0.1415 0.0279 0.7634 0.5821 0.1858 0.1913 0.0357 0.9734 0.1476 0.1126 0.8063 0.7358 0.6134 A(:,:,7) = 0.3193 0.3617 0.0696 0.0930 0.0512 0.3005 0.3717 0.7611 0.1327 0.0488 0.2818 0.9682 0.0764 0.5082 0.2708 0.4779 0.8955 0.5679 0.5082 0.3547 0.5203 0.5925 0.1709 0.5471 0.3000 0.9350 0.2345 0.3619 0.5048 0.8939 0.3648 0.2662 0.9814 0.4986 0.9096 0.4890 0.2694 0.8248 0.5343 0.2441 0.5333 0.2233 0.9180 0.4169 0.0170 0.0228 0.7690 0.3116 0.5135 0.5390 0.4938 0.0898 0.7995 0.2498 0.7948 0.5766 0.6237 0.8762 0.4989 0.3795 0.9118 0.3074 0.2737 0.1429 0.4185 0.9699 0.9822 0.0301 0.9429 0.2622 0.3566 0.4247 0.3022 0.9378 0.3262 0.9905 0.6861 0.3128 0.5277 0.6980 0.2519 0.6620 0.6875 0.8307 0.4184 0.6991 0.2333 0.5966 0.8833 0.5314 0.1373 0.6257 0.1040 0.1249 0.4461 0.4974 0.7273 0.4146 0.5279 0.9409 A(:,:,8) = 0.4353 0.7302 0.2865 0.2020 0.9804 0.6984 0.7778 0.8684 0.3418 0.9081 0.6517 0.9106 0.1951 0.4958 0.8679 0.8337 0.4748 0.0145 0.9666 0.5801 0.2804 0.2524 0.8756 0.9522 0.4611 0.6926 0.4953 0.6400 0.5223 0.8320 0.9030 0.2899 0.6122 0.4084 0.9981 0.8848 0.5836 0.5732 0.7786 0.3776 0.7483 0.0688 0.3894 0.5425 0.1050 0.4022 0.4303 0.5966 0.1518 0.7990 0.1064 0.7283 0.8945 0.1750 0.4025 0.6934 0.3549 0.4613 0.1171 0.8622 0.2490 0.5596 0.3736 0.4206 0.8199 0.9214 0.0670 0.0711 0.1884 0.0066 0.7362 0.8925 0.4215 0.3185 0.1588 0.5104 0.1630 0.1674 0.5303 0.2228 0.6173 0.7543 0.1785 0.7416 0.5689 0.7286 0.6533 0.3237 0.3161 0.8844 0.3399 0.3002 0.2627 0.5051 0.5460 0.5653 0.8444 0.2482 0.2435 0.0997 A(:,:,9) = 0.0673 0.3773 0.1935 0.0154 0.2609 0.0985 0.2897 0.4687 0.9301 0.5389 0.6846 0.1287 0.6622 0.7973 0.7471 0.6741 0.0563 0.7711 0.1225 0.7975 0.6282 0.0239 0.1948 0.7742 0.0506 0.8993 0.8934 0.2828 0.9748 0.1818 0.4373 0.2842 0.8607 0.1340 0.9685 0.1542 0.3252 0.1243 0.5719 0.5801 0.2655 0.3001 0.4336 0.6450 0.1485 0.6319 0.8454 0.6249 0.3433 0.6746 0.7452 0.7444 0.7559 0.0086 0.0996 0.1140 0.9927 0.8129 0.5144 0.7313 0.6851 0.4888 0.4279 0.1881 0.5472 0.1742 0.0434 0.7278 0.6423 0.9250 0.5097 0.6411 0.7078 0.9619 0.3257 0.8768 0.4743 0.3574 0.5617 0.3158 0.6484 0.0509 0.4083 0.9382 0.2469 0.0311 0.8987 0.3476 0.9585 0.4863 0.9083 0.7910 0.5742 0.9971 0.2363 0.2789 0.7870 0.1780 0.5512 0.9477 A(:,:,10) = 0.5947 0.8066 0.9015 0.4619 0.3965 0.9482 0.6991 0.8723 0.5291 0.8855 0.0538 0.2954 0.0441 0.1352 0.7768 0.6269 0.5091 0.0815 0.7010 0.3271 0.1466 0.6864 0.2441 0.8805 0.4484 0.5547 0.9018 0.1423 0.8114 0.9676 0.1753 0.5905 0.5949 0.2389 0.8163 0.6847 0.7880 0.8883 0.7631 0.8368 0.0299 0.2564 0.5753 0.6199 0.5137 0.6743 0.4529 0.2205 0.1704 0.1746 0.4229 0.4425 0.8492 0.3832 0.0198 0.6929 0.4917 0.1851 0.3959 0.7674 0.3874 0.9443 0.8433 0.4130 0.0524 0.9968 0.7087 0.3529 0.6391 0.7214 0.9268 0.9234 0.4008 0.9193 0.7806 0.9984 ...

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 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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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ans = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 ans = 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 ans = 13.3000