Cody

Solution 2048059

Submitted on 5 Dec 2019 by Ondrej Tomecek
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.2107 0.4223 0.1610 0.2279 0.7039 0.8495 0.8094 0.8155 0.4821 0.6052 0.7619 0.6545 0.4090 0.5465 0.7572 0.1051 0.1015 0.7789 0.9409 0.1031 0.5818 0.6383 0.3054 0 0.2430 0.2749 0.8317 0.9915 0.9455 0.2845 0.9466 0.7358 0.3372 0.7050 0.4878 0.1451 0.2037 0.5941 0.6864 0.6477 0.3379 0.2368 0.6522 0.6557 0.2504 0.2976 0.4123 0.8506 0.0676 0.3095 0.1785 0.6586 0.4593 0.8980 0.8271 0.4767 0.9873 0.0790 0.2712 0.8371 0.4124 0.3772 0.5609 0.3901 0.8422 0.5367 0.9611 0.4779 0.8137 0.4393 0.4579 0.1018 0.9928 0.4189 0.3825 0.4557 0.1317 0.4983 0.4951 0.0783 0.2192 0.6269 0.0553 0.8003 0.2561 0.5163 0.7862 0.1192 0.5011 0.9565 0.9061 0.2433 0.3258 0.2190 0.1208 0.6229 0.2367 0.2756 0.3891 0.4792 A(:,:,2) = 0.2162 0 0.8607 0.2648 0.5907 0.2544 0.1247 0.0513 0.8571 0.1943 0.4259 0.5077 0.5700 0.2295 0.6867 0.6416 0.9060 0.0798 0.9734 0.6043 0.5732 0.8650 0.0208 0.7211 0.8191 0.5001 0.3261 0.9341 0.5075 0.3601 0.2541 0.1538 0.0110 0.7638 0.4327 0.2089 0.9048 0.9525 0.6385 0.5690 0.4219 0.0476 0.6234 0.7796 0.4977 0.8000 0.1321 0.2226 0.1103 0.6732 0.6340 0.1402 0.6959 0.2107 0.1151 0.4805 0.3628 0.7130 0.9603 0.1791 0.8549 0.7830 0.3995 0.4019 0.8666 0.0903 0.1062 0.3296 0.0086 0.7415 0.9365 0.7106 0.6663 0.5086 0.2822 0.8658 0.1242 0.9073 0.8098 0.4952 0.8999 0.5123 0.9932 0.9733 0.8437 0.8372 0.3918 0.6686 0.2633 0.9052 0.1677 0.0263 0.0081 0.2821 0.8103 0.3784 0.6584 0.7903 0.4512 0.2955 A(:,:,3) = 0.3640 0.5508 0.2052 0.5934 0.0343 0.8014 0.7082 0.4014 0.7086 0.0155 0.3652 0.5829 0.5710 0.2465 0.4602 0.3979 0.8574 0.4373 0.7269 0.6200 0.5372 0.9572 0.2447 0.9398 0.5569 0.2674 0.6398 0.6766 0.4391 0.3340 0.8317 0.1182 0.0401 0.6647 0.8593 0.4205 0.8319 0.3631 0.3168 0.9741 0.6166 0.1113 0.5411 0.4701 0.4226 0 0.7207 0.7785 0.7218 0.1933 0.0405 0.8504 0.6605 0.4415 0.0035 0.0773 0.7233 0.9282 0.7905 0.0715 0.1407 0.7689 0.8226 0.3188 0.3004 0.0702 0.7039 0.5311 0.9130 0.6940 0.3812 0.6268 0.3974 0.8195 0.8261 0.4951 0.3974 0.9583 0.1384 0.6743 0.4844 0.4575 0.8724 0.5221 0.1098 0.9972 0.4764 0.2923 0.1541 0.3353 0.0097 0.4161 0.2324 0.5908 0.7820 0.4181 0.8705 0.3106 0.0012 0.1440 A(:,:,4) = 0.1845 0.2586 0.8694 0.6421 0.4207 0.8265 0.8633 0.2389 0.8083 0.6863 0.9212 0.1355 0.9791 0.6980 0.1083 0.1798 0.8402 0.0042 0.6440 0.9175 0.2896 0.4529 0.8198 0.2781 0.0161 0.4982 0.8520 0.5281 0.6106 0.3345 0.1086 0.1122 0.2662 0.2379 0.1468 0.7489 0.7698 0.9661 0.5363 0.5573 0.2526 0.3751 0.2999 0.7294 0.4204 0.6054 0.6581 0.4521 0.5333 0.3123 0.6503 0.2485 0.3554 0.8546 0.9085 0.4989 0.5850 0.2359 0.4830 0.3658 0.6352 0.8033 0.0999 0.4504 0.9319 0.2263 0.7458 0.3703 0.6552 0.3557 0.3573 0.8879 0.3637 0.8975 0.0453 0.6120 0.7875 0.9830 0.5114 0.7709 0.1142 0.3273 0.7525 0.3803 0.7730 0.4347 0.5064 0.7209 0.8932 0.2390 0.7035 0.2826 0.1108 0.7047 0.4332 0.3501 0.7953 0.7347 0.2798 0.2167 A(:,:,5) = 0.7113 0.1313 0.3117 0.5011 0.7604 0.4873 0.3856 0.5187 0.9946 0.0360 0.0343 0.7290 0.4702 0.8256 0.3608 0.9245 0.8746 0.1278 0.6915 0.8573 0.2112 0.1700 0.5466 0.4944 0.9682 0.4727 0.9538 0.4069 0.4101 0.2828 0.9667 0.0596 0.5491 0.0707 0.9087 0.7445 0.7439 0.1936 0.2154 0.6301 0.8357 0.0811 0.5000 0.5109 0.9990 0.9518 0.7291 0.5019 0.7796 0.7350 0.6582 0.5828 0.2728 0.8723 0.4047 0.1429 0.0802 0.0021 0.4018 0.6592 0.3972 0.7326 0.7190 0.5062 0.4328 0.9244 0.1961 0.6789 0.4320 0.5058 0.0160 0.6510 0.1347 0.9274 0.3464 0.2442 0.5009 0.6219 0.0459 0.3221 0.9175 0.2048 0.3317 0.8586 0.3732 0.0298 0.0068 0.2123 0.8283 0.6421 0.0516 0.1871 0.8565 0.4394 0.4386 0.3760 0.4119 0.0872 0.9529 0.8163 A(:,:,6) = 0.1584 0.0506 0.5527 0.3121 0.1163 0.3407 0.1179 0.6396 0.0654 0.4484 0.9077 0.9679 0.4041 0.9464 0.1724 0.4336 0.6912 0.0487 0.6732 0.3705 0.1698 0.6484 0.3428 0.3037 0.8641 0.5394 0.4457 0.9391 0.4662 0.4602 0.7117 0.6407 0.8091 0.7245 0.5321 0.4919 0.4650 0.7449 0.8067 0.4818 0.9241 0.1010 0.3550 0.4976 0.7392 0.2553 0.0490 0.5383 0.0168 0.7087 0.6284 0.5258 0.6648 0.3549 0.7506 0.7948 0.7344 0.8626 0.5075 0.5171 0.6817 0.1618 0.5917 0.5757 0.1739 0.4108 0.3511 0.4063 0.5430 0.4965 0.3067 0.3261 0.6848 0.7642 0.3273 0.4649 0.2554 0.5837 0.5493 0.9082 0.2835 0.2199 0.6566 0.1112 0.8995 0.0154 0.6345 0.8673 0.6269 0.4422 0.1821 0.0680 0.9071 0.7428 0.6213 0.3348 0.6558 0.3251 0.2158 0.5911 A(:,:,7) = 0.8880 0.7346 0.3887 0.8809 0.6746 0.8402 0.6359 0.9775 0.5848 0.4015 0.4491 0.0522 0.8440 0.4319 0.8885 0.4610 0.2436 0.2321 0.7042 0.2666 0.9814 0.1130 0.0697 0.2970 0.0202 0.2286 0.1663 0.5450 0.7388 0.1667 0.3138 0.7568 0.1939 0.6613 0.2363 0.6210 0.9450 0.0130 0.6143 0.7718 0.0369 0.1069 0.3556 0.9198 0.7921 0.9777 0.6259 0.8059 0.3512 0.0296 0.2051 0.2802 0.2248 0.1420 0.3399 0.6387 0.3125 0.8842 0.9232 0.0294 0.9856 0.2699 0.1781 0.2224 0.6052 0.8516 0.2263 0.2959 0.2425 0.1659 0.6807 0.7980 0.3313 0.3966 0.4824 0.1504 0.7595 0.5755 0.8790 0.9444 0.4103 0.8692 0.9532 0.7950 0.1362 0.9290 0.8120 0.5512 0.0645 0.4550 0.6781 0.0636 0.0556 0.8995 0.2373 0.3558 0.5804 0.5740 0.1638 0.0153 A(:,:,8) = 0.3480 0.5988 0.6389 0.9034 0.3512 0.3355 0.5236 0.2484 0.7496 0.3405 0.9143 0.4918 0.9094 0.2301 0.5900 0.3031 0.9415 0.7507 0.3551 0.7928 0.4065 0.8845 0.0794 0.9037 0.3950 0.9068 0.7593 0.3597 0.1665 0.5449 0.7545 0.6234 0.0295 0.0532 0.0343 0.2258 0.8573 0.8078 0.2148 0.7057 0.8930 0.3470 0.9257 0.9546 0.1547 0.8799 0.4913 0.2859 0.0210 0.3831 0.7614 0.8126 0.7712 0.8442 0.1934 0.8473 0.0846 0.3632 0.7587 0.7477 0.4405 0.2249 0.8575 0.0368 0.1023 0.2987 0.7250 0.7500 0.1323 0.9292 0.2313 0.0522 0.6357 0.8642 0.9548 0.7548 0.6039 0.5923 0.8490 0.0134 0.8361 0.9449 0.8727 0.2182 0.4630 0.3580 0.4234 0.8423 0.9525 0.2345 0.1694 0.0400 0.3618 0.9793 0.9688 0.7336 0.6044 0.5842 0.9802 0.6383 A(:,:,9) = 0.4886 0.3708 0.1045 0.8283 0.7178 0.4263 0.7454 0.9100 0.7181 0.5286 0.4794 0.1821 0.3275 0.8754 0.2852 0.0964 0.0400 0.9356 0.2378 0.5069 0.4955 0.8993 0.4551 0.5397 0.1011 0.4939 0.3145 0.8743 0.6267 0.6078 0.7814 0.5269 0.6343 0.8927 0.9814 0.7804 0.2602 0.5387 0.3242 0.6351 0.5146 0.8752 0.2798 0.5693 0.5203 0.0566 0.5820 0.9073 0.3929 0.9128 0.1637 0.8882 0.8678 0.3559 0.3626 0.2935 0.6913 0.2850 0.7610 0.9703 0.3500 0.2173 0.5421 0.1697 0.8608 0.8379 0.1054 0.0425 0.3700 0.6918 0.5558 0.4756 0.1536 0.8306 0.0246 0.0563 0.5165 0.4898 0.2961 0.1000 0.3803 0.5407 0.8260 0.9028 0.6352 0.6554 0.9117 0.2531 0.3536 0.3975 0.7847 0.4790 0.3328 0.3434 0.3634 0.1961 0.5103 0.8783 0.1386 0.3644 A(:,:,10) = 0.6261 0.3762 0.9931 0.8982 0.1561 0.8420 0.9045 0.3013 0.3817 0.6000 0.2987 0.2794 0.5052 0.4549 0.4233 0.4489 0.7761 0.3352 0.1701 0.9259 0.5082 0.3617 0.7945 0.8468 0.8258 0.9260 0.3518 0.5665 0.8817 0.8701 0.1176 0.3462 0.5368 0.1355 0.5399 0.0129 0.2569 0.9710 0.7764 0.5061 0.0414 0.3070 0.6918 0.2084 0.6804 0.5809 0.0017 0.4602 0.4810 0.4839 0.3181 0.1549 0.9753 0.7556 0.7386 0.8112 0.0969 0.9993 0.9333 0.1218 0.3091 0.0816 0.1963 0.3040 0.7255 0.4446 0.4486 0.0438 0.7813 0.5848 0.1997 0.7222 0.3119 0.6601 0.5968 0.9939 ...

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