Cody

Solution 2279670

Submitted on 14 May 2020 by Laza Álmos
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.9375 0.9306 0.5173 0.2312 0.9695 0.7160 0.1328 0.5475 0.9833 0.5327 0.5784 0.1186 0.4359 0.5934 0.4866 0.1691 0.6889 0.7301 0.4350 0.5802 0.9705 0.4803 0.7711 0 0.5027 0.0809 0.5628 0.3907 0.6286 0.6670 0.7729 0.1457 0.9331 0.3649 0.3888 0.4102 0.0411 0.8330 0.8605 0.6315 0.7873 0.8316 0.0950 0.7208 0.5491 0.8114 0.3523 0.4576 0.9101 0.0489 0.7279 0.5836 0.4553 0.9706 0.3314 0.3607 0.1407 0.8300 0.2810 0.6599 0.4719 0.3960 0.4148 0.3533 0.5943 0.4349 0.2736 0.4459 0.4634 0.1428 0.6486 0.5356 0.6445 0.8220 0.2377 0.7763 0.3516 0.2321 0.7949 0.9630 0.4045 0.0275 0.8454 0.9072 0.5349 0.4257 0.7767 0.0996 0.3364 0.6637 0.9605 0.6184 0.0923 0.1562 0.4006 0.8132 0.3030 0.5490 0.4373 0.8093 A(:,:,2) = 0.7243 0 0.7333 0.8199 0.8723 0.1407 0.2703 0.7789 0.5739 0.9461 0.5428 0.4096 0.7352 0.9069 0.6316 0.7802 0.2216 0.1203 0.8314 0.9214 0.5063 0.1611 0.9266 0.1803 0.6885 0.6633 0.1143 0.2891 0.0630 0.9721 0.2313 0.5537 0.4244 0.9534 0.7791 0.5387 0.9611 0.6319 0.8333 0.4322 0.1967 0.8958 0.4965 0.8894 0.4462 0.5325 0.8760 0.9042 0.8295 0.1057 0.9523 0.1360 0.2842 0.8377 0.4853 0.6508 0.2538 0.3293 0.4837 0.7650 0.9936 0.7473 0.0538 0.3916 0.1665 0.5625 0.5310 0.5669 0.4783 0.4011 0.8747 0.0398 0.1296 0.5487 0.2763 0.8697 0.8566 0.2516 0.0028 0.6897 0.1930 0.0889 0.0483 0.3927 0.4765 0.8520 0.6166 0.8364 0.8545 0.2326 0.3989 0.6058 0.6240 0.1147 0.6258 0.5798 0.4005 0.3054 0.7979 0.9678 A(:,:,3) = 0.3685 0.9516 0.4705 0.1364 0.4618 0.3262 0.0512 0.4768 0.1869 0.6650 0.2396 0.6351 0.1055 0.1851 0.9846 0.3891 0.0272 0.1797 0.6165 0.4332 0.2905 0.6344 0.5546 0.0423 0.6168 0.5963 0.4722 0.3304 0.3267 0.8452 0.5242 0.4692 0.8770 0.2195 0.6521 0.7890 0.0338 0.8339 0.4581 0.9768 0.8757 0.1009 0.7063 0.8198 0.0303 0 0.7790 0.1337 0.0613 0.3961 0.2059 0.0382 0.4521 0.0618 0.1944 0.7089 0.9950 0.8973 0.6935 0.6455 0.3403 0.5858 0.1832 0.8702 0.7539 0.4127 0.3422 0.3661 0.3984 0.1927 0.5133 0.2251 0.4754 0.6603 0.7463 0.3587 0.1510 0.1959 0.6762 0.0911 0.8558 0.7456 0.6008 0.0452 0.5110 0.9817 0.4464 0.5734 0.5228 0.4087 0.3111 0.6034 0.1194 0.1066 0.1167 0.0997 0.6699 0.2096 0.4981 0.1057 A(:,:,4) = 0.3895 0.5342 0.8131 0.5205 0.0733 0.4696 0.5634 0.7396 0.0276 0.6241 0.3396 0.6769 0.4524 0.3215 0.1183 0.6090 0.4150 0.2706 0.3228 0.2840 0.3652 0.0502 0.7444 0.5501 0.0387 0.2628 0.5707 0.5945 0.0016 0.5925 0.2294 0.1231 0.1801 0.8273 0.0242 0.6884 0.0517 0.0415 0.5671 0.5969 0.6388 0.3985 0.5295 0.2072 0.1588 0.1064 0.1156 0.5401 0.5320 0.4420 0.6117 0.7204 0.6077 0.2228 0.4067 0.0258 0.2256 0.5549 0.5974 0.2434 0.5619 0.0552 0.3472 0.8579 0.0832 0.9284 0.8746 0.2572 0.1414 0.1165 0.2112 0.6362 0.8802 0.4166 0.6762 0.5946 0.8464 0.6578 0.8344 0.8847 0.4567 0.1596 0.5790 0.3159 0.7945 0.7689 0.8911 0.0296 0.3359 0.1698 0.3791 0.7189 0.2351 0.8303 0.9631 0.6224 0.1826 0.3668 0.6103 0.8807 A(:,:,5) = 0.2284 0.1578 0.8623 0.5103 0.0094 0.4622 0.0151 0.1416 0.5603 0.0034 0.0545 0.7368 0.4164 0.9935 0.2997 0.3977 0.3415 0.1411 0.3215 0.3597 0.9638 0.9844 0.6860 0.3602 0.8778 0.0181 0.2680 0.7630 0.3199 0.2128 0.1282 0.2787 0.9812 0.7037 0.9544 0.9951 0.8052 0.0709 0.7017 0.6304 0.5860 0.6889 0.8171 0.3678 0.9527 0.6280 0.7152 0.0491 0.0296 0.8956 0.7128 0.6241 0.2338 0.8856 0.8997 0.4000 0.9289 0.8829 0.2550 0.0168 0.3098 0.8119 0.1811 0.5925 0.4794 0.4750 0.2172 0.7894 0.4626 0.3147 0.9517 0.6804 0.8422 0.1451 0.6100 0.8858 0.0562 0.7906 0.2792 0.8863 0.0163 0.2085 0.2287 0.0437 0.0991 0.4356 0.9849 0.7030 0.3339 0.3585 0.5169 0.4668 0.4693 0.1658 0.6973 0.2105 0.4443 0.2940 0.0854 0.0846 A(:,:,6) = 0.5082 0.1805 0.0700 0.7169 0.6323 0.4668 0.4251 0.1397 0.3157 0.9149 0.3715 0.8587 0.6124 0.1125 0.1858 0.9719 0.9802 0.7990 0.5666 0.7843 0.7227 0.3480 0.8186 0.8164 0.0485 0.4097 0.3530 0.4759 0.4853 0.2343 0.6327 0.2184 0.8434 0.3942 0.9532 0.2217 0.6855 0.7441 0.0160 0.0688 0.7661 0.7766 0.4727 0.7273 0.3682 0.6115 0.4602 0.7561 0.9412 0.3853 0.0240 0.1185 0.3902 0.8425 0.2131 0.1369 0.3903 0.9339 0.8968 0.1920 0.7334 0.0241 0.3657 0.4435 0.4594 0.9563 0.6211 0.3781 0.1109 0.5194 0.9337 0.8322 0.5376 0.2475 0.3740 0.9802 0.3756 0.0128 0.8059 0.5388 0.1991 0.0448 0.8675 0.6562 0.1160 0.5416 0.9641 0.1250 0.5045 0.7547 0.3771 0.6370 0.1684 0.4394 0.8483 0.2627 0.7233 0.5509 0.7126 0.9594 A(:,:,7) = 0.5984 0.6865 0.1745 0.9387 0.7158 0.0989 0.1261 0.9080 0.7196 0.9263 0.6424 0.5034 0.2325 0.1701 0.4653 0.7633 0.4980 0.9380 0.0638 0.1894 0.8067 0.1865 0.2986 0.0989 0.1415 0.5110 0.2855 0.7664 0.4701 0.2466 0.6575 0.4964 0.4352 0.0707 0.9488 0.4367 0.9972 0.6065 0.1478 0.7340 0.9953 0.3138 0.1468 0.8535 0.4329 0.1608 0.5621 0.6245 0.6794 0.1295 0.3875 0.7771 0.7737 0.0800 0.6671 0.3707 0.3608 0.1696 0.5770 0.5506 0.9661 0.9364 0.4132 0.3215 0.0608 0.4273 0.8170 0.8929 0.6010 0.9842 0.8809 0.7115 0.9165 0.6201 0.5157 0.9136 0.0817 0.8296 0.2374 0.6861 0.9885 0.5792 0.4551 0.2091 0.5344 0.1361 0.9242 0.2452 0.8329 0.5342 0.2128 0.7027 0.2317 0.0137 0.5514 0.5566 0.6357 0.1615 0.3663 0.1045 A(:,:,8) = 0.9632 0.6106 0.3829 0.9367 0.1581 0.5317 0.6004 0.3814 0.3383 0.0235 0.7857 0.4771 0.5495 0.2642 0.8769 0.8116 0.5450 0.2996 0.1809 0.2828 0.7972 0.2936 0.1620 0.2827 0.3307 0.6515 0.2394 0.4165 0.7943 0.7034 0.2902 0.9827 0.9773 0.2097 0.2910 0.2953 0.1486 0.0901 0.1314 0.0565 0.3001 0.3533 0.3384 0.3356 0.3989 0.1321 0.7578 0.0544 0.6432 0.0595 0.1353 0.5212 0.2503 0.1466 0.1193 0.5039 0.8627 0.4418 0.4357 0.8935 0.2349 0.2318 0.9763 0.3371 0.1480 0.0761 0.6311 0.1154 0.5033 0.8674 0.6330 0.6919 0.3161 0.4427 0.1321 0.1409 0.7869 0.9528 0.5601 0.0381 0.5152 0.7820 0.6744 0.4588 0.8571 0.7424 0.4531 0.5787 0.4717 0.1245 0.8469 0.4386 0.8336 0.5892 0.7203 0.3219 0.4523 0.6193 0.7979 0.0232 A(:,:,9) = 0.1684 0.3226 0.9538 0.9039 0.5427 0.4045 0.1650 0.8945 0.3885 0.0398 0.8099 0.2523 0.2724 0.4258 0.1752 0.5456 0.9910 0.3636 0.5133 0.7298 0.5261 0.1420 0.6202 0.4239 0.7617 0.8875 0.7205 0.4033 0.5441 0.9534 0.5395 0.8938 0.5776 0.2983 0.2611 0.6019 0.8083 0.5165 0.5013 0.2651 0.8952 0.7942 0.2548 0.2054 0.1280 0.1563 0.4946 0.0721 0.4108 0.6527 0.7392 0.8330 0.1880 0.9025 0.1472 0.5862 0.2609 0.3807 0.5355 0.2648 0.7039 0.8903 0.3374 0.2327 0.6149 0.4742 0.1404 0.7946 0.2593 0.3198 0.0296 0.4630 0.4362 0.4730 0.3282 0.8030 0.5032 0.2363 0.1882 0.1139 0.4762 0.7945 0.8520 0.7250 0.1640 0.7763 0.4469 0.7442 0.3054 0.9821 0.3463 0.1818 0.5648 0.1763 0.9177 0.4159 0.0987 0.4412 0.0570 0.2226 A(:,:,10) = 0.5827 0.6530 0.3231 0.4202 0.0932 0.4624 0.2611 0.0449 0.0526 0.1466 0.2696 0.8955 0.7787 0.1961 0.8006 0.7254 0.6581 0.9728 0.4265 0.7662 0.1693 0.9395 0.9265 0.1695 0.4971 0.2716 0.4896 0.0123 0.4713 0.4602 0.4705 0.4752 0.3930 0.2829 0.7024 0.3759 0.7337 0.5239 0.0736 0.7105 0.3503 0.5636 0.4790 0.2878 0.7130 0.7953 0.0926 0.7781 0.2794 0.7696 0.5659 0.8802 0.1478 0.5390 0.3469 0.7070 0.1745 0.8377 0.9063 0.9785 0.5722 0.0915 0.8789 0.2508 0.0442 0.0433 0.6269 0.7657 0.0526 0.9106 0.1751 0.6659 0.7484 0.4339 0.3352 0.2744 ...

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