Cody

Solution 1648748

Submitted on 15 Oct 2018 by Martin C.
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.0241 0.3974 0.7158 0.3586 0.7113 0.7852 0.2856 0.7270 0.5106 0.0685 0.2662 0.6696 0.3257 0.9603 0.3111 0.4481 0.7645 0.9304 0.2165 0.6514 0.6843 0.3640 0.2228 0 0.3049 0.6793 0.4751 0.5046 0.5296 0.0766 0.3826 0.4494 0.4545 0.5323 0.4075 0.4741 0.8679 0.3928 0.5420 0.3465 0.3126 0.2426 0.1588 0.1328 0.4554 0.9275 0.6767 0.1584 0.7454 0.7991 0.6291 0.1562 0.2311 0.0509 0.0852 0.6318 0.7031 0.8043 0.9488 0.5458 0.0413 0.7048 0.4018 0.4956 0.7633 0.5051 0.5303 0.4376 0.5380 0.8618 0.5369 0.0556 0.0713 0.7993 0.3041 0.6740 0.1769 0.1583 0.0083 0.3537 0.2937 0.9442 0.1013 0.3077 0.3011 0.3986 0.0633 0.7147 0.2411 0.0682 0.2081 0.4189 0.2150 0.4666 0.0027 0.0921 0.2159 0.0071 0.1535 0.9331 A(:,:,2) = 0.9327 0 0.2051 0.0142 0.2627 0.9066 0.0189 0.4146 0.3861 0.7337 0.9801 0.8199 0.0938 0.1747 0.9226 0.1074 0.2436 0.9314 0.7078 0.7864 0.7097 0.1209 0.8951 0.7367 0.5555 0.2107 0.3897 0.2045 0.1484 0.5613 0.2850 0.6324 0.4266 0.7472 0.3877 0.3319 0.6315 0.4720 0.3660 0.7799 0.2563 0.5453 0.5369 0.6233 0.6982 0.1925 0.7169 0.0987 0.0204 0.2487 0.1205 0.3688 0.0452 0.9047 0.4955 0.5656 0.2141 0.3338 0.2729 0.1456 0.9557 0.3936 0.4849 0.7861 0.7299 0.5549 0.1337 0.6647 0.5845 0.8117 0.5573 0.3748 0.8021 0.9323 0.3078 0.2902 0.6514 0.7432 0.1263 0.9977 0.5779 0.4283 0.7587 0.3699 0.5820 0.0332 0.8378 0.5986 0.9199 0.9690 0.8899 0.8532 0.5940 0.8466 0.0428 0.1281 0.7468 0.0425 0.5688 0.8771 A(:,:,3) = 0.3972 0.8440 0.7687 0.2761 0.0463 0.5529 0.2433 0.2104 0.8176 0.6542 0.5663 0.0336 0.8787 0.2196 0.5854 0.8636 0.0421 0.0535 0.1235 0.1012 0.2231 0.7021 0.7971 0.0172 0.3593 0.1335 0.5967 0.9650 0.9961 0.9485 0.6000 0.7961 0.0647 0.6270 0.2167 0.7068 0.6497 0.1916 0.0800 0.6763 0.6845 0.7258 0.4946 0.5926 0.6344 0 0.1728 0.9000 0.4811 0.4791 0.5233 0.4634 0.0806 0.5545 0.9570 0.0229 0.2523 0.8935 0.0627 0.0680 0.0516 0.8980 0.9479 0.3445 0.6654 0.9717 0.3142 0.0982 0.0811 0.9439 0.5064 0.4307 0.4376 0.6992 0.6159 0.9547 0.0033 0.2126 0.8400 0.6957 0.0913 0.2549 0.6747 0.3895 0.2983 0.0738 0.6364 0.9842 0.4836 0.9238 0.7180 0.4073 0.6005 0.2629 0.4592 0.9404 0.2720 0.4845 0.9242 0.3921 A(:,:,4) = 0.9881 0.0136 0.1915 0.4807 0.9713 0.6127 0.8332 0.7313 0.7417 0.7813 0.5887 0.2371 0.5882 0.3141 0.2101 0.0980 0.8915 0.7887 0.7480 0.2612 0.5417 0.8703 0.9991 0.6805 0.0282 0.2527 0.1594 0.1698 0.7048 0.9233 0.6602 0.7902 0.6833 0.2804 0.1435 0.6760 0.8909 0.6168 0.6673 0.7993 0.3533 0.9312 0.9470 0.5612 0.3732 0.4178 0.4340 0.0397 0.6214 0.6786 0.3002 0.9026 0.4262 0.3910 0.6138 0.6629 0.1027 0.3472 0.1702 0.7263 0.1910 0.3081 0.7868 0.2582 0.4099 0.8646 0.6353 0.0096 0.7260 0.5049 0.6103 0.5649 0.3926 0.6773 0.4952 0.1626 0.0005 0.1055 0.4672 0.2641 0.5264 0.7210 0.6320 0.1436 0.9496 0.9901 0.4153 0.1705 0.3189 0.2891 0.3432 0.8392 0.2533 0.7490 0.4848 0.0519 0.1000 0.0165 0.0095 0.0646 A(:,:,5) = 0.0267 0.2453 0.9955 0.2298 0.6662 0.5281 0.2362 0.2805 0.1600 0.5433 0.0873 0.6547 0.7994 0.1985 0.6668 0.5425 0.7733 0.3846 0.6181 0.7177 0.7457 0.5524 0.5174 0.5939 0.3049 0.1916 0.8608 0.5408 0.6068 0.2801 0.7207 0.0010 0.3662 0.2354 0.4467 0.9863 0.8385 0.4482 0.5717 0.3201 0.3858 0.2651 0.3473 0.4794 0.4444 0.5799 0.7563 0.6575 0.9367 0.2524 0.5782 0.4673 0.9110 0.3013 0.3618 0.1358 0.3467 0.2308 0.5489 0.8659 0.0772 0.6564 0.7367 0.8233 0.9076 0.2166 0.6523 0.8325 0.7461 0.8894 0.0395 0.7189 0.0987 0.7308 0.7240 0.2003 0.4962 0.6396 0.9251 0.5339 0.7904 0.2455 0.5702 0.0855 0.0918 0.7146 0.2051 0.6201 0.6145 0.9076 0.1519 0.5847 0.9957 0.9817 0.9282 0.3918 0.2350 0.5614 0.3947 0.0439 A(:,:,6) = 0.7783 0.6499 0.8311 0.4399 0.6027 0.9398 0.4835 0.8133 0.8332 0.9399 0.6447 0.6904 0.6977 0.4602 0.4593 0.7511 0.8460 0.7248 0.5315 0.6316 0.4355 0.4067 0.8753 0.1976 0.4869 0.7629 0.6722 0.5554 0.4755 0.2895 0.0437 0.9763 0.6392 0.1495 0.2191 0.7893 0.9884 0.9235 0.7630 0.6084 0.0753 0.5628 0.8966 0.5312 0.6698 0.0633 0.7108 0.6342 0.1847 0.2542 0.1674 0.5697 0.5542 0.3893 0.0301 0.7715 0.5529 0.2143 0.2010 0.1035 0.1046 0.2540 0.0743 0.8322 0.4957 0.1295 0.6941 0.4820 0.6952 0.3314 0.0199 0.6167 0.0468 0.3595 0.2856 0.0970 0.9522 0.6077 0.1792 0.0461 0.3540 0.7367 0.1406 0.9968 0.1741 0.0047 0.9149 0.6053 0.1675 0.3067 0.6994 0.5074 0.9667 0.0639 0.6280 0.2398 0.0282 0.3384 0.0120 0.0238 A(:,:,7) = 0.0802 0.6584 0.7772 0.5738 0.5055 0.7351 0.5087 0.1942 0.1470 0.2334 0.1927 0.1461 0.7359 0.0129 0.2939 0.4017 0.8037 0.1795 0.3889 0.3540 0.6184 0.9180 0.0169 0.1797 0.0290 0.3344 0.8535 0.0802 0.6678 0.8939 0.5609 0.2723 0.8138 0.3008 0.0856 0.9306 0.2881 0.7085 0.8745 0.0587 0.5507 0.9881 0.6613 0.7354 0.0446 0.2230 0.3796 0.7820 0.9852 0.3834 0.3228 0.0494 0.5772 0.7751 0.4913 0.4733 0.1112 0.4470 0.1720 0.1613 0.9907 0.4932 0.3773 0.9908 0.8751 0.1763 0.9976 0.4492 0.3821 0.2396 0.9395 0.1267 0.5286 0.0383 0.9279 0.8767 0.1111 0.2341 0.5587 0.5693 0.0328 0.3411 0.1921 0.5792 0.9907 0.3004 0.4172 0.5843 0.6200 0.8551 0.4949 0.3088 0.8717 0.7121 0.1825 0.2201 0.6321 0.8892 0.3055 0.3173 A(:,:,8) = 0.1964 0.9123 0.6389 0.3200 0.3737 0.9193 0.8173 0.5011 0.5066 0.9538 0.8501 0.0637 0.4694 0.4930 0.7607 0.0791 0.0190 0.9834 0.5043 0.3364 0.9670 0.7696 0.9950 0.4476 0.1067 0.2475 0.3656 0.6138 0.8852 0.7614 0.0038 0.6975 0.3170 0.9254 0.9708 0.8785 0.2480 0.5114 0.5991 0.2226 0.0093 0.0573 0.3539 0.4294 0.3831 0.2670 0.1533 0.5064 0.3831 0.7675 0.4630 0.9145 0.3217 0.0200 0.5986 0.3999 0.2532 0.7072 0.4730 0.7986 0.8476 0.7081 0.8282 0.5398 0.4170 0.5900 0.4518 0.6038 0.4153 0.4360 0.9170 0.0129 0.3057 0.0704 0.9961 0.6243 0.8602 0.3603 0.7007 0.6056 0.1347 0.0755 0.6436 0.8859 0.3523 0.5483 0.8389 0.4532 0.9924 0.3826 0.6679 0.5102 0.0276 0.6560 0.7032 0.1797 0.8999 0.9396 0.5333 0.8864 A(:,:,9) = 0.0454 0.8980 0.5580 0.8647 0.7297 0.0547 0.9911 0.2230 0.0387 0.7417 0.2291 0.1186 0.8200 0.3194 0.5569 0.1940 0.8415 0.1856 0.6281 0.3266 0.9433 0.6022 0.0709 0.7089 0.1776 0.3415 0.9242 0.3751 0.6684 0.3109 0.1716 0.5080 0.1785 0.6929 0.6652 0.9317 0.6297 0.6106 0.5950 0.1214 0.0432 0.0141 0.5688 0.1496 0.7073 0.8592 0.8370 0.4036 0.7019 0.5920 0.0819 0.7946 0.6916 0.5448 0.4180 0.5793 0.4507 0.6370 0.5790 0.5647 0.9371 0.6044 0.5648 0.3166 0.9539 0.4523 0.7414 0.4259 0.0042 0.4660 0.5040 0.0089 0.1661 0.7464 0.2003 0.9745 0.7694 0.3392 0.6582 0.4228 0.8288 0.3826 0.7842 0.9472 0.8290 0.6399 0.8323 0.8508 0.8830 0.1677 0.2351 0.4556 0.6748 0.8688 0.6101 0.3911 0.8334 0.5235 0.4334 0.0632 A(:,:,10) = 0.4647 0.9419 0.7159 0.1415 0.1098 0.2630 0.9528 0.7869 0.9573 0.2391 0.8637 0.1537 0.6861 0.0207 0.7101 0.3978 0.8568 0.7377 0.2431 0.1051 0.2634 0.5260 0.6014 0.5326 0.1911 0.0769 0.1944 0.1490 0.7157 0.9223 0.4207 0.3987 0.9279 0.1601 0.8106 0.6546 0.7328 0.5567 0.8287 0.4699 0.2686 0.2005 0.0117 0.7649 0.9430 0.1457 0.6774 0.0586 0.0640 0.2785 0.1733 0.7188 0.8044 0.5082 0.5521 0.8727 0.0295 0.9758 0.7969 0.8482 0.3916 0.7163 0.6446 0.3292 0.3524 0.6158 0.4818 0.8028 0.6796 0.5709 0.2442 0.7022 0.5675 0.2682 0.4842 0.2755 0.4422 0.6162 0.8485 ...

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

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