Cody

Solution 1679131

Submitted on 22 Nov 2018 by steph26
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.5632 0.1295 0.2763 0.8615 0.1298 0.9244 0.8888 0.4233 0.5580 0.2876 0.3994 0.1699 0.4952 0.6569 0.7149 0.4695 0.8872 0.3567 0.7741 0.4285 0.3770 0.7986 0.2897 0 0.2526 0.0560 0.6999 0.6866 0.0071 0.7315 0.0661 0.7441 0.9454 0.3532 0.3551 0.1067 0.7954 0.7380 0.3670 0.7775 0.9995 0.4702 0.3690 0.5676 0.6861 0.1406 0.5940 0.1879 0.3961 0.2473 0.1808 0.1509 0.8065 0.0830 0.8294 0.7361 0.6116 0.0367 0.1453 0.8374 0.7821 0.5286 0.8049 0.2685 0.1296 0.0159 0.9918 0.6279 0.0429 0.9758 0.0121 0.8211 0.3319 0.9428 0.4326 0.1234 0.0542 0.2139 0.3152 0.0426 0.8700 0.7086 0.8906 0.3123 0.9897 0.9133 0.3702 0.4704 0.6988 0.0587 0.8008 0.3838 0.4069 0.2719 0.4163 0.1301 0.2300 0.3964 0.1286 0.5663 A(:,:,2) = 0.1748 0 0.7961 0.2147 0.0601 0.4708 0.5183 0.8899 0.8026 0.4731 0.9770 0.6485 0.7953 0.0279 0.1447 0.2524 0.1033 0.3168 0.6417 0.3287 0.3576 0.9925 0.2955 0.3190 0.8273 0.5748 0.4131 0.1120 0.6978 0.8320 0.4117 0.3360 0.7116 0.0751 0.6317 0.1246 0.9826 0.6741 0.2067 0.1516 0.3325 0.0716 0.8950 0.6545 0.6354 0.9313 0.6659 0.0481 0.1826 0.5499 0.2947 0.2046 0.5458 0.3971 0.8435 0.7545 0.3662 0.7300 0.1325 0.6882 0.6873 0.2511 0.0992 0.5414 0.8303 0.6986 0.7230 0.2421 0.2453 0.6873 0.6906 0.7905 0.7095 0.5653 0.6989 0.3373 0.8345 0.6974 0.5951 0.0996 0.0519 0.8965 0.1560 0.7326 0.7120 0.4715 0.9479 0.0473 0.7820 0.1357 0.0646 0.8416 0.1399 0.1089 0.8207 0.4620 0.9626 0.6719 0.4112 0.1967 A(:,:,3) = 0.2173 0.8640 0.5083 0.2074 0.5314 0.9856 0.3979 0.4994 0.3126 0.8235 0.3081 0.3938 0.0673 0.1004 0.8056 0.7044 0.3103 0.2614 0.6970 0.0506 0.9608 0.6089 0.0455 0.1650 0.2978 0.8892 0.9512 0.3757 0.4989 0.6322 0.8536 0.7130 0.5720 0.9388 0.1551 0.2439 0.1373 0.0109 0.8472 0.6007 0.4816 0.9028 0.3054 0.9352 0.2908 0 0.5138 0.5571 0.1164 0.3884 0.7994 0.6284 0.1094 0.7248 0.5750 0.1056 0.7108 0.9822 0.8746 0.8690 0.8536 0.9108 0.6064 0.3448 0.0820 0.0754 0.8374 0.3196 0.2122 0.4870 0.0490 0.5112 0.8647 0.9041 0.1426 0.8546 0.7832 0.3921 0.2392 0.6342 0.4464 0.6777 0.6580 0.8572 0.0978 0.6406 0.0197 0.1807 0.7342 0.9810 0.2745 0.5524 0.2971 0.1140 0.7461 0.1411 0.9319 0.4804 0.8497 0.5434 A(:,:,4) = 0.0060 0.7703 0.4742 0.0177 0.8274 0.9386 0.6140 0.2443 0.9619 0.3789 0.0299 0.2376 0.8481 0.4995 0.5934 0.2462 0.2166 0.1976 0.6839 0.3747 0.4269 0.6557 0.7077 0.2200 0.9148 0.0682 0.0796 0.2907 0.3761 0.9290 0.5471 0.9131 0.7501 0.7286 0.4172 0.2692 0.0281 0.8285 0.8609 0.4347 0.8830 0.1568 0.6159 0.7770 0.6002 0.5403 0.0595 0.2748 0.2770 0.0899 0.1358 0.4554 0.7385 0.7008 0.4457 0.6315 0.6306 0.0315 0.1423 0.7193 0.7742 0.8791 0.9626 0.3856 0.4248 0.9143 0.4603 0.3268 0.0402 0.6603 0.0346 0.0568 0.0695 0.8993 0.2918 0.9673 0.0135 0.1759 0.0719 0.0772 0.9783 0.1437 0.9806 0.5031 0.5312 0.2844 0.1542 0.0842 0.0388 0.7655 0.7267 0.6706 0.8545 0.5904 0.7029 0.0754 0.6466 0.5322 0.8296 0.0624 A(:,:,5) = 0.8677 0.5282 0.6103 0.5479 0.5564 0.9834 0.0643 0.2563 0.3390 0.7684 0.6859 0.7297 0.8303 0.8017 0.7731 0.9945 0.4989 0.7283 0.2782 0.1859 0.0692 0.3948 0.6050 0.0605 0.8504 0.4357 0.1918 0.8329 0.5442 0.9001 0.8426 0.6460 0.7162 0.2167 0.4568 0.6853 0.6809 0.6113 0.8370 0.0646 0.4267 0.4791 0.6239 0.4060 0.1135 0.2003 0.5407 0.8878 0.0347 0.4598 0.3706 0.9330 0.4868 0.6239 0.5364 0.4496 0.4296 0.0850 0.2453 0.5279 0.0575 0.0068 0.3217 0.9377 0.1644 0.0340 0.3593 0.9297 0.1431 0.6519 0.8000 0.8464 0.5551 0.0341 0.9541 0.9572 0.5828 0.8383 0.5222 0.9739 0.4490 0.4247 0.2970 0.3417 0.3113 0.7882 0.3873 0.4873 0.4208 0.7924 0.1524 0.8956 0.2807 0.8217 0.5143 0.2568 0.7702 0.0136 0.6712 0.1903 A(:,:,6) = 0.3028 0.3546 0.1753 0.4161 0.9268 0.9672 0.4480 0.2264 0.2518 0.6943 0.6089 0.1541 0.7074 0.2390 0.5643 0.1787 0.8878 0.4839 0.7093 0.2876 0.6917 0.0015 0.3572 0.2995 0.7786 0.9994 0.6045 0.8304 0.0386 0.6809 0.4903 0.3533 0.3938 0.4589 0.9775 0.5936 0.4645 0.4379 0.3241 0.0626 0.1247 0.7989 0.7019 0.6830 0.0395 0.7108 0.7896 0.6817 0.0236 0.3411 0.4919 0.3180 0.9185 0.0851 0.8663 0.4863 0.5655 0.2506 0.5673 0.6941 0.1856 0.2241 0.7357 0.0834 0.2933 0.3370 0.2499 0.1160 0.0940 0.1556 0.9537 0.4960 0.9439 0.7081 0.5755 0.0645 0.8228 0.4627 0.0737 0.9900 0.3265 0.7393 0.4473 0.0265 0.3712 0.0831 0.8452 0.2054 0.0410 0.0182 0.6115 0.4521 0.5851 0.1843 0.3079 0.2125 0.3861 0.8932 0.5294 0.2481 A(:,:,7) = 0.9056 0.5528 0.1555 0.4997 0.5890 0.0938 0.7632 0.5463 0.0709 0.2384 0.8225 0.4111 0.8085 0.3715 0.2865 0.0003 0.9019 0.2254 0.1066 0.0178 0.6803 0.2716 0.0695 0.1034 0.1627 0.3946 0.3234 0.4094 0.7643 0.9098 0.5751 0.6852 0.5789 0.9127 0.0638 0.5731 0.8300 0.6080 0.7695 0.0858 0.0194 0.0802 0.1789 0.3175 0.0186 0.8919 0.2354 0.1676 0.3206 0.7697 0.3671 0.0798 0.1900 0.5121 0.7426 0.0416 0.1199 0.7466 0.4082 0.1936 0.7394 0.5385 0.6256 0.6650 0.4797 0.5141 0.9151 0.0772 0.8807 0.2007 0.1766 0.6934 0.2304 0.8962 0.9125 0.9495 0.2402 0.7132 0.6652 0.7500 0.1489 0.8355 0.9026 0.8617 0.0900 0.3268 0.6423 0.8196 0.7529 0.5191 0.3103 0.1669 0.2089 0.9299 0.4933 0.4551 0.5964 0.1568 0.9248 0.1741 A(:,:,8) = 0.2207 0.2875 0.7499 0.5419 0.2594 0.7354 0.3513 0.4713 0.9067 0.0123 0.8004 0.5231 0.8438 0.7329 0.7663 0.6456 0.3959 0.6057 0.8992 0.8607 0.4595 0.5386 0.6731 0.4156 0.9721 0.1918 0.3706 0.9633 0.3619 0.0494 0.9754 0.0877 0.2350 0.4309 0.8119 0.9151 0.2078 0.2654 0.0449 0.3718 0.4713 0.6951 0.9718 0.8905 0.8476 0.2197 0.0149 0.8522 0.9631 0.9193 0.3272 0.4485 0.9989 0.4485 0.6819 0.7963 0.0418 0.1047 0.8308 0.4329 0.0261 0.4760 0.6877 0.3024 0.0985 0.4494 0.8798 0.8124 0.8683 0.6314 0.3448 0.9736 0.2015 0.5963 0.9084 0.6271 0.5626 0.6384 0.2812 0.1781 0.5215 0.9586 0.2489 0.7149 0.7504 0.8640 0.8068 0.4482 0.0285 0.5957 0.8510 0.7051 0.0424 0.8681 0.0264 0.5549 0.1416 0.7262 0.5706 0.6388 A(:,:,9) = 0.2672 0.1642 0.1472 0.5673 0.4904 0.3369 0.4364 0.0739 0.7035 0.7571 0.4433 0.7799 0.0069 0.6394 0.3757 0.5330 0.7840 0.3515 0.8228 0.2016 0.5229 0.1291 0.9077 0.0511 0.5413 0.3962 0.0437 0.8230 0.5570 0.6224 0.8132 0.4295 0.7342 0.4687 0.6524 0.9821 0.4666 0.3734 0.7623 0.7215 0.3420 0.8182 0.9340 0.8310 0.0473 0.0153 0.0371 0.2194 0.5597 0.9020 0.4173 0.7706 0.6278 0.5677 0.0923 0.2444 0.5255 0.9094 0.5760 0.2562 0.0964 0.8638 0.7680 0.7579 0.5547 0.8375 0.1792 0.5920 0.4270 0.3082 0.0022 0.0821 0.6296 0.8355 0.7560 0.9345 0.6718 0.2164 0.8718 0.5279 0.8146 0.7489 0.4364 0.4781 0.8554 0.3926 0.6677 0.6744 0.5864 0.0774 0.1833 0.7694 0.5494 0.7247 0.1590 0.5275 0.6972 0.7794 0.2468 0.8072 A(:,:,10) = 0.2095 0.1068 0.5724 0.9663 0.9510 0.0746 0.9627 0.2632 0.5474 0.3314 0.3442 0.8404 0.7405 0.5996 0.9373 0.0371 0.1565 0.6325 0.1782 0.8655 0.7345 0.8225 0.2341 0.7414 0.9862 0.8499 0.0187 0.9324 0.9330 0.0028 0.7529 0.0175 0.4599 0.6568 0.2219 0.4974 0.5181 0.1982 0.6305 0.1984 0.3899 0.8245 0.1175 0.4888 0.1093 0.8607 0.3763 0.0196 0.5997 0.2788 0.4465 0.8527 0.8741 0.7881 0.3591 0.9668 0.4734 0.0071 0.8646 0.2644 0.0406 0.1394 0.8777 0.4903 0.1051 0.6729 0.3998 0.3850 0.7107 0.6914 0.9556 0.3994 0.7153 0.8797 0.9331 0.5428 ...

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