Cody

Solution 1354154

Submitted on 22 Nov 2017 by Yanyan Liu
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 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')

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

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

A = 0 0 0 0 0 8 0 25 2 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')

A(:,:,1) = 0.2075 0.9093 0.1677 0.7258 0.9120 0.2931 0.5459 0.0931 0.3433 0.6254 0.3165 0.9035 0.7944 0.8899 0.6310 0.0249 0.9337 0.2058 0.9648 0.0018 0.7918 0.9084 0.1812 0 0.9654 0.4023 0.7682 0.5709 0.6588 0.9240 0.3762 0.4061 0.8248 0.4896 0.7394 0.4876 0.9598 0.0736 0.2636 0.8852 0.8171 0.4276 0.8737 0.7167 0.3077 0.0212 0.1100 0.5972 0.2039 0.9989 0.0078 0.0794 0.0911 0.5615 0.2706 0.7600 0.3088 0.4182 0.6671 0.8993 0.1185 0.7110 0.3354 0.2288 0.4544 0.3788 0.2328 0.9596 0.7414 0.6186 0.6432 0.1314 0.5643 0.0295 0.2597 0.9491 0.5207 0.4023 0.2361 0.5508 0.1321 0.2491 0.9513 0.3460 0.6988 0.5724 0.0157 0.6423 0.4382 0.7874 0.6621 0.0987 0.6733 0.2920 0.3218 0.5887 0.7267 0.2844 0.1195 0.4271 A(:,:,2) = 0.4113 0 0.7989 0.5554 0.4916 0.4670 0.0076 0.0407 0.9199 0.2408 0.7061 0.8835 0.3424 0.5107 0.9496 0.6056 0.3334 0.2821 0.3660 0.7901 0.8564 0.0777 0.9566 0.2833 0.8194 0.1667 0.1097 0.9485 0.7271 0.0137 0.2552 0.7141 0.9996 0.7222 0.2861 0.2216 0.6459 0.5231 0.7606 0.2743 0.9327 0.8862 0.8417 0.2348 0.0503 0.5185 0.2416 0.0061 0.9560 0.4117 0.3075 0.3453 0.0347 0.4055 0.9854 0.8943 0.0267 0.4480 0.5635 0.3124 0.2226 0.4162 0.4092 0.5821 0.3133 0.3301 0.9620 0.7787 0.4104 0.0356 0.0401 0.5891 0.8455 0.5252 0.2837 0.9588 0.1114 0.8384 0.4755 0.5464 0.0279 0.3929 0.1596 0.0588 0.4162 0.4758 0.7613 0.8408 0.6735 0.4072 0.1333 0.4646 0.0791 0.2475 0.1658 0.5473 0.5880 0.1144 0.8907 0.3111 A(:,:,3) = 0.2537 0.3011 0.6058 0.1867 0.7016 0.7834 0.0378 0.6972 0.5008 0.7209 0.3649 0.3146 0.6920 0.2330 0.8845 0.1833 0.6734 0.4406 0.1458 0.9559 0.6289 0.0360 0.0072 0.2952 0.1866 0.4320 0.3567 0.5881 0.0073 0.8363 0.8505 0.9156 0.5978 0.7006 0.7423 0.8690 0.0089 0.5170 0.4544 0.5470 0.2031 0.3768 0.3915 0.2146 0.3919 0 0.5253 0.8362 0.3360 0.7170 0.3454 0.6154 0.0648 0.0676 0.8962 0.6287 0.9431 0.6603 0.4487 0.8162 0.9005 0.1824 0.4176 0.8827 0.5328 0.4363 0.7503 0.1251 0.2236 0.8331 0.8550 0.3270 0.6703 0.4737 0.1610 0.5971 0.7375 0.8894 0.3349 0.3916 0.8141 0.2468 0.0815 0.4038 0.6253 0.2356 0.1513 0.3014 0.9606 0.4780 0.3099 0.4355 0.5002 0.0139 0.5321 0.3162 0.7435 0.1133 0.9881 0.0930 A(:,:,4) = 0.7203 0.2028 0.5698 0.3450 0.7098 0.0057 0.1837 0.7777 0.2384 0.4947 0.5118 0.8847 0.5742 0.7406 0.6485 0.4567 0.1270 0.5593 0.3793 0.6871 0.7643 0.8250 0.7179 0.6102 0.4461 0.2312 0.5385 0.6077 0.1009 0.9256 0.1580 0.4675 0.9702 0.9799 0.5535 0.6414 0.1538 0.5426 0.7867 0.3995 0.7584 0.7691 0.3998 0.4618 0.8855 0.4004 0.8314 0.2133 0.3409 0.4474 0.7591 0.5764 0.1676 0.5830 0.0343 0.6910 0.2880 0.3871 0.6280 0.1544 0.0898 0.1910 0.9255 0.1342 0.2823 0.1883 0.2885 0.1485 0.0474 0.6517 0.0171 0.5964 0.1831 0.5080 0.5700 0.3502 0.0744 0.6762 0.2134 0.0269 0.0930 0.0728 0.7230 0.0375 0.6973 0.2788 0.4601 0.0653 0.7540 0.1464 0.8624 0.1443 0.2539 0.6766 0.8520 0.3966 0.5030 0.7429 0.1229 0.9111 A(:,:,5) = 0.2806 0.9701 0.7078 0.1154 0.5527 0.9741 0.6603 0.0355 0.2848 0.5721 0.1191 0.1287 0.0116 0.8584 0.1193 0.8859 0.4102 0.2543 0.3191 0.0682 0.5169 0.5212 0.8115 0.4758 0.1538 0.4763 0.5773 0.5358 0.6006 0.4684 0.2503 0.0766 0.9776 0.6766 0.8622 0.9190 0.8667 0.2390 0.2808 0.3954 0.4865 0.5294 0.3483 0.2338 0.5490 0.3654 0.8039 0.4715 0.9235 0.5497 0.0717 0.1351 0.4443 0.2265 0.9038 0.8703 0.3948 0.0907 0.8892 0.7950 0.1832 0.6970 0.9850 0.3415 0.6853 0.3761 0.6618 0.5086 0.2926 0.9058 0.0389 0.6183 0.7420 0.9946 0.0102 0.3699 0.3408 0.8177 0.3081 0.8358 0.4846 0.9176 0.0569 0.0482 0.8755 0.1239 0.2914 0.9733 0.5090 0.1732 0.6653 0.8892 0.3899 0.4271 0.1577 0.5070 0.8438 0.0460 0.2432 0.1815 A(:,:,6) = 0.8273 0.2792 0.6269 0.4858 0.7575 0.0940 0.1044 0.9205 0.7729 0.3549 0.0988 0.8062 0.9427 0.1887 0.1913 0.1696 0.2205 0.7949 0.4114 0.9378 0.9499 0.1413 0.6408 0.3858 0.6330 0.9772 0.1194 0.2638 0.2645 0.0671 0.2361 0.2246 0.8061 0.0035 0.8272 0.1541 0.7535 0.0833 0.4853 0.9377 0.1107 0.8759 0.8266 0.3426 0.3470 0.0627 0.4172 0.7862 0.7937 0.5108 0.9629 0.5004 0.7820 0.2935 0.8163 0.8781 0.7678 0.2594 0.7863 0.3380 0.7377 0.1687 0.7431 0.3991 0.3845 0.0439 0.3434 0.3457 0.2956 0.3224 0.8826 0.5325 0.2736 0.7209 0.9364 0.1409 0.1359 0.4863 0.8076 0.0482 0.1192 0.7990 0.0915 0.6895 0.6584 0.5292 0.2305 0.1959 0.6471 0.4088 0.5421 0.7924 0.7882 0.7011 0.4183 0.3340 0.9327 0.3158 0.8917 0.8471 A(:,:,7) = 0.3810 0.7906 0.8181 0.4374 0.0100 0.0534 0.1630 0.7479 0.3770 0.1483 0.2949 0.0865 0.9196 0.8651 0.4348 0.1858 0.0393 0.3322 0.3207 0.0392 0.8488 0.8643 0.0291 0.3471 0.1536 0.8030 0.0206 0.8331 0.1682 0.0371 0.8250 0.1307 0.8001 0.0507 0.5618 0.7827 0.2407 0.7209 0.4940 0.9555 0.2027 0.1899 0.0748 0.9796 0.0843 0.2833 0.0214 0.5024 0.5110 0.8481 0.4523 0.8743 0.9526 0.9691 0.0147 0.6061 0.0135 0.0184 0.7555 0.7658 0.6641 0.5819 0.0756 0.6407 0.4763 0.6386 0.1808 0.4399 0.6177 0.5090 0.2539 0.8670 0.9249 0.8014 0.1148 0.5487 0.5060 0.0398 0.5435 0.7155 0.9320 0.3547 0.5068 0.5297 0.1677 0.5810 0.8113 0.7947 0.3484 0.8840 0.2332 0.3758 0.5193 0.1045 0.8889 0.9664 0.2561 0.6054 0.2824 0.5904 A(:,:,8) = 0.5191 0.0301 0.2739 0.8113 0.8077 0.5935 0.7107 0.4635 0.6073 0.0934 0.6497 0.2351 0.0202 0.0418 0.3346 0.8740 0.5436 0.0858 0.3658 0.8968 0.6977 0.9369 0.6038 0.4383 0.8399 0.0723 0.3965 0.9988 0.1472 0.8699 0.4704 0.9247 0.5932 0.5507 0.3191 0.5749 0.4399 0.1437 0.4508 0.6310 0.3583 0.0909 0.1069 0.7835 0.9576 0.7293 0.7216 0.3587 0.0003 0.7861 0.0365 0.0698 0.8550 0.4971 0.9038 0.8430 0.3923 0.8679 0.3522 0.8715 0.9753 0.0759 0.8318 0.3951 0.5417 0.1760 0.1041 0.1941 0.0479 0.8526 0.3326 0.7051 0.4937 0.9644 0.0917 0.0857 0.6835 0.1834 0.7007 0.2107 0.1084 0.9364 0.3212 0.7006 0.7854 0.3147 0.0681 0.4778 0.1900 0.4325 0.4207 0.5477 0.5278 0.2050 0.4042 0.8475 0.6204 0.7393 0.2482 0.8907 A(:,:,9) = 0.6472 0.9046 0.5935 0.4031 0.7815 0.6021 0.7528 0.9401 0.9081 0.3027 0.6268 0.6854 0.6872 0.5709 0.0270 0.2362 0.4793 0.0016 0.4163 0.6025 0.3003 0.2086 0.7265 0.6698 0.6798 0.3154 0.6262 0.1244 0.5047 0.5466 0.3517 0.0521 0.0240 0.1226 0.5969 0.7865 0.2941 0.2338 0.5721 0.9375 0.6911 0.1986 0.7268 0.9551 0.8444 0.4883 0.2662 0.5955 0.7700 0.3062 0.9536 0.8775 0.5099 0.3322 0.5766 0.1338 0.9425 0.5369 0.4167 0.9692 0.9481 0.7876 0.7681 0.3004 0.7558 0.3666 0.3420 0.5575 0.8429 0.3578 0.4770 0.3718 0.6730 0.5784 0.2088 0.8315 0.3422 0.7262 0.8335 0.1319 0.9154 0.2538 0.1476 0.9513 0.5998 0.5970 0.0791 0.4614 0.1216 0.9264 0.8442 0.1220 0.9460 0.5255 0.4163 0.2024 0.9687 0.9331 0.2478 0.8149 A(:,:,10) = 0.1097 0.1506 0.0836 0.9393 0.7735 0.4164 0.7686 0.9781 0.3441 0.7203 0.2881 0.4331 0.1958 0.4484 0.0458 0.0996 0.6761 0.6551 0.0986 0.4342 0.3129 0.8309 0.4950 0.1441 0.9474 0.8218 0.4866 0.1713 0.3474 0.5079 0.9475 0.2574 0.9915 0.6411 0.4670 0.6166 0.4687 0.2129 0.5892 0.5092 0.2478 0.5796 0.3766 0.4880 0.2009 0.0032 0.4835 0.2949 0.6805 0.5168 0.7392 0.9705 0.8903 0.5532 0.4859 0.5229 0.7555 0.7841 0.0834 0.0143 0.3634 0.0252 0.5318 0.0767 0.8426 0.2617 0.2941 0.7604 0.5126 0.9044 0.8545 0.4100 0.2451 0.6076 0.0817 0.4293 ...

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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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 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 ...

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

A = 13.3000 B = 13.3000