Cody

Solution 2044219

Submitted on 3 Dec 2019 by Vít Lochman
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.1039 0.4965 0.6771 0.6481 0.1206 0.5092 0.6047 0.9641 0.2309 0.3834 0.7238 0.0433 0.1172 0.2631 0.8741 0.1188 0.8928 0.2715 0.0155 0.0450 0.6583 0.1134 0.4310 0 0.5529 0.0747 0.6706 0.7246 0.2196 0.6437 0.4426 0.1057 0.6652 0.2036 0.4959 0.6809 0.6935 0.9353 0.0618 0.1381 0.3010 0.5895 0.5042 0.1573 0.1767 0.7448 0.9975 0.9455 0.5839 0.9600 0.0020 0.9855 0.0148 0.8415 0.6425 0.9318 0.7926 0.8960 0.8696 0.2462 0.9707 0.5697 0.0915 0.3957 0.9995 0.7657 0.4820 0.1622 0.7982 0.5785 0.3057 0.0195 0.3779 0.9147 0.0745 0.2555 0.1759 0.5771 0.2841 0.8853 0.0240 0.4630 0.5532 0.9603 0.2644 0.2769 0.0211 0.8503 0.5415 0.0601 0.2259 0.5689 0.1096 0.2217 0.3171 0.0759 0.0534 0.4429 0.6951 0.4885 A(:,:,2) = 0.1496 0 0.1519 0.6198 0.0280 0.5413 0.3603 0.8361 0.5550 0.4172 0.8699 0.4286 0.5985 0.2070 0.7413 0.8221 0.3571 0.7644 0.7314 0.4395 0.8909 0.3596 0.8448 0.3491 0.7096 0.2019 0.8655 0.7182 0.9458 0.1667 0.0107 0.1049 0.0380 0.6676 0.0895 0.5219 0.8774 0.1541 0.7011 0.6329 0.2320 0.0145 0.3218 0.5964 0.0331 0.4212 0.5233 0.2734 0.6284 0.7511 0.0018 0.9873 0.3963 0.2949 0.2363 0.6303 0.9343 0.4594 0.1658 0.0690 0.9584 0.2396 0.8407 0.3447 0.1527 0.2510 0.1745 0.2341 0.2448 0.8426 0.5955 0.0687 0.4506 0.1185 0.8436 0.9146 0.2097 0.4377 0.4007 0.4574 0.2457 0.0662 0.2329 0.8981 0.1416 0.0586 0.4184 0.4174 0.0771 0.5829 0.4359 0.7946 0.2394 0.0782 0.4181 0.3799 0.1804 0.3123 0.4773 0.9510 A(:,:,3) = 0.7777 0.9967 0.4377 0.9366 0.1326 0.5739 0.7738 0.7822 0.5796 0.9120 0.7321 0.7024 0.1109 0.6067 0.4022 0.7599 0.7060 0.4883 0.8975 0.5880 0.5938 0.9566 0.8086 0.8533 0.1744 0.6671 0.2299 0.9197 0.4814 0.0005 0.8932 0.0574 0.3586 0.9517 0.9139 0.1767 0.7614 0.8894 0.4235 0.5537 0.8666 0.0140 0.3261 0.6070 0.4794 0 0.9892 0.6021 0.3526 0.3973 0.0233 0.5885 0.4570 0.0063 0.8337 0.9553 0.5019 0.9662 0.2685 0.0234 0.1785 0.1220 0.0178 0.0031 0.8750 0.7793 0.5942 0.3712 0.1016 0.1248 0.6316 0.7924 0.0262 0.1689 0.3365 0.1045 0.1852 0.6367 0.1529 0.8526 0.5014 0.0810 0.6572 0.6389 0.6034 0.4851 0.7746 0.5785 0.1551 0.2854 0.7232 0.4380 0.6334 0.1231 0.1119 0.3648 0.4747 0.0298 0.8093 0.0257 A(:,:,4) = 0.6282 0.6308 0.0445 0.9348 0.9211 0.1969 0.6429 0.5862 0.3881 0.2956 0.2021 0.6756 0.1989 0.6684 0.9062 0.6870 0.6602 0.9386 0.7904 0.3431 0.5377 0.5655 0.3605 0.4561 0.2595 0.8706 0.6815 0.8694 0.4996 0.3925 0.1326 0.3438 0.8033 0.8887 0.6235 0.7087 0.3856 0.9511 0.4605 0.8980 0.6080 0.8877 0.9655 0.3632 0.1503 0.0227 0.8607 0.1222 0.8108 0.8194 0.9294 0.9761 0.2647 0.8913 0.8944 0.1861 0.4980 0.5517 0.1973 0.3025 0.5790 0.9772 0.3819 0.2466 0.3514 0.4887 0.9619 0.5149 0.2353 0.0469 0.8765 0.2228 0.2017 0.1172 0.7888 0.8124 0.1756 0.0102 0.8924 0.9254 0.8699 0.1184 0.0403 0.9669 0.3198 0.8490 0.9342 0.3825 0.9685 0.5486 0.7109 0.1481 0.6655 0.3501 0.1948 0.3082 0.4694 0.6248 0.0761 0.2741 A(:,:,5) = 0.7054 0.8831 0.2918 0.6806 0.7463 0.8111 0.6716 0.6629 0.3181 0.5697 0.3911 0.5652 0.5694 0.3424 0.2374 0.0209 0.4252 0.4209 0.7594 0.3815 0.1853 0.8700 0.0683 0.6701 0.5213 0.4784 0.6080 0.7571 0.8841 0.5157 0.0604 0.4072 0.6457 0.3560 0.1420 0.0491 0.6137 0.7496 0.5134 0.9167 0.9952 0.7390 0.5588 0.0740 0.5904 0.8989 0.1075 0.3612 0.4649 0.9763 0.6418 0.1467 0.0196 0.7505 0.6588 0.2755 0.3454 0.3976 0.4156 0.6695 0.9411 0.9756 0.8756 0.7235 0.8244 0.5414 0.8976 0.3839 0.9621 0.2732 0.7367 0.0353 0.4273 0.4324 0.2577 0.3094 0.1940 0.5697 0.3136 0.8919 0.8400 0.7106 0.1409 0.5073 0.5510 0.0100 0.6132 0.6243 0.7181 0.4904 0.9245 0.0976 0.1274 0.4033 0.6531 0.9419 0.6364 0.0381 0.4905 0.4885 A(:,:,6) = 0.8910 0.4590 0.5422 0.6891 0.1431 0.5209 0.4030 0.2523 0.0918 0.7626 0.3621 0.6708 0.8768 0.3938 0.3756 0.1763 0.0626 0.5352 0.0680 0.9860 0.8999 0.2684 0.2677 0.8914 0.1375 0.0863 0.2137 0.7243 0.6477 0.8355 0.9307 0.3413 0.5500 0.1854 0.8367 0.6024 0.1906 0.7550 0.7392 0.4503 0.5351 0.8769 0.9356 0.8921 0.1268 0.5884 0.7094 0.4730 0.0219 0.4436 0.3954 0.3188 0.5088 0.0603 0.9188 0.4345 0.2580 0.5689 0.5870 0.5659 0.6963 0.3760 0.1449 0.4592 0.1401 0.1454 0.3629 0.8425 0.2882 0.6781 0.3429 0.3079 0.0964 0.9876 0.5732 0.7950 0.7374 0.3421 0.7288 0.5064 0.4842 0.8184 0.8042 0.4050 0.8060 0.9401 0.2256 0.7988 0.7774 0.4376 0.5981 0.9468 0.0647 0.7060 0.7795 0.2867 0.1636 0.6644 0.8599 0.1827 A(:,:,7) = 0.0247 0.2411 0.2648 0.9011 0.5070 0.9986 0.9774 0.6232 0.3351 0.4303 0.4060 0.0191 0.2601 0.5823 0.6982 0.2811 0.8140 0.3243 0.6090 0.2351 0.8726 0.0716 0.8201 0.1908 0.3249 0.4886 0.0280 0.3407 0.6601 0.0692 0.7131 0.0784 0.6799 0.2787 0.7343 0.8752 0.3868 0.6015 0.1614 0.8459 0.1923 0.5286 0.9454 0.8952 0.9893 0.2414 0.6354 0.1779 0.8462 0.1955 0.2072 0.4981 0.1069 0.1510 0.5756 0.1578 0.9656 0.5427 0.1132 0.7902 0.6344 0.4169 0.4463 0.5057 0.8168 0.4984 0.6873 0.3504 0.9547 0.7994 0.4302 0.0815 0.6459 0.0657 0.4674 0.8551 0.9428 0.5625 0.9936 0.5263 0.6580 0.8698 0.7181 0.6823 0.3080 0.1122 0.9261 0.4439 0.8616 0.4933 0.8811 0.8222 0.6066 0.2091 0.3106 0.0624 0.7018 0.3030 0.4087 0.3557 A(:,:,8) = 0.7041 0.6063 0.9739 0.2910 0.7835 0.4701 0.0956 0.3914 0.8358 0.8659 0.9984 0.2071 0.7320 0.1425 0.4501 0.5007 0.8224 0.7760 0.4597 0.6999 0.2683 0.5631 0.1210 0.7730 0.3068 0.3206 0.3107 0.5707 0.4226 0.5465 0.0712 0.4619 0.6229 0.9780 0.1075 0.9084 0.8574 0.2377 0.4564 0.8305 0.3930 0.0084 0.1183 0.5455 0.6207 0.9886 0.9525 0.2930 0.1612 0.5445 0.3411 0.4892 0.5496 0.8450 0.7371 0.4396 0.8891 0.0474 0.5512 0.6954 0.4846 0.0868 0.5843 0.2017 0.2262 0.5622 0.7207 0.9334 0.8976 0.1335 0.9338 0.6102 0.1963 0.0196 0.6594 0.6271 0.5255 0.3854 0.3081 0.6774 0.3381 0.4288 0.1668 0.4751 0.8622 0.2623 0.4185 0.7642 0.6283 0.2342 0.9762 0.9959 0.0484 0.4188 0.0330 0.5027 0.3499 0.7873 0.6069 0.2967 A(:,:,9) = 0.2762 0.2704 0.3866 0.7015 0.1453 0.6118 0.4512 0.8780 0.1730 0.3998 0.3285 0.9663 0.0206 0.4234 0.6567 0.0098 0.5115 0.9441 0.3409 0.1477 0.8535 0.0161 0.1484 0.9810 0.0270 0.8009 0.5383 0.5292 0.0949 0.2417 0.7500 0.9414 0.0275 0.7497 0.0937 0.0609 0.6145 0.9297 0.8652 0.6368 0.4131 0.6173 0.3308 0.1239 0.3639 0.3867 0.7499 0.2139 0.3109 0.3433 0.2891 0.2984 0.8791 0.4840 0.2776 0.5032 0.4459 0.2187 0.8432 0.4122 0.3826 0.4158 0.4006 0.2110 0.4657 0.0574 0.6961 0.0535 0.2953 0.5945 0.1301 0.5087 0.1932 0.7667 0.1979 0.4696 0.7486 0.8194 0.6366 0.9046 0.7331 0.1603 0.3425 0.2507 0.6721 0.2050 0.1459 0.9237 0.5782 0.3821 0.2269 0.9851 0.6505 0.7238 0.1214 0.0972 0.0641 0.0965 0.5807 0.5877 A(:,:,10) = 0.0077 0.9398 0.1531 0.0468 0.3385 0.2950 0.1736 0.1607 0.0963 0.0348 0.5421 0.8104 0.7386 0.5932 0.5074 0.4384 0.7183 0.0608 0.7150 0.1886 0.3474 0.9165 0.5367 0.9785 0.7936 0.5612 0.3592 0.6341 0.6152 0.8849 0.9680 0.7089 0.1669 0.5729 0.8192 0.1732 0.0849 0.5090 0.1722 0.7263 0.9235 0.4130 0.1387 0.7914 0.6608 0.2055 0.8998 0.9702 0.8949 0.1095 0.8296 0.9964 0.6289 0.1009 0.7248 0.9924 0.0809 0.3638 0.6241 0.0014 0.4133 0.1334 0.3732 0.3444 0.5793 0.0447 0.9927 0.1784 0.7240 0.6434 0.0022 0.7683 0.4057 0.5731 0.0022 0.0998 ...

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

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