Cody

# Problem 824. Set the array elements whose value is 13 to 0

Solution 2021854

Submitted on 14 Nov 2019 at 20:55 by Romain Demory
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.7530 0.9003 0.4269 0.6921 0.2139 0.3294 0.5549 0.2292 0.3046 0.7384 0.4055 0.6860 0.7968 0.7069 0.7354 0.6187 0.6849 0.0808 0.8360 0.0573 0.7982 0.2184 0.8403 0 0.4150 0.2320 0.9852 0.6091 0.5638 0.3079 0.0248 0.3745 0.3967 0.1397 0.0240 0.5056 0.9520 0.5917 0.2670 0.7465 0.4084 0.9464 0.1508 0.8558 0.9683 0.2204 0.8902 0.6466 0.1057 0.7222 0.7517 0.1316 0.0194 0.5963 0.7420 0.4242 0.9116 0.6467 0.2280 0.0867 0.4035 0.5338 0.2052 0.7258 0.7240 0.3587 0.0212 0.5633 0.5404 0.0294 0.5998 0.2637 0.3813 0.8651 0.7064 0.4534 0.4265 0.2517 0.9853 0.3936 0.8323 0.5494 0.6267 0.6932 0.5002 0.8422 0.5753 0.2955 0.7307 0.4762 0.4152 0.5019 0.6245 0.1280 0.4535 0.5824 0.8806 0.7664 0.4009 0.6070 A(:,:,2) = 0.0553 0 0.0962 0.4011 0.8943 0.1539 0.1196 0.6440 0.6041 0.5952 0.2163 0.3019 0.6785 0.5876 0.3955 0.0216 0.5455 0.0815 0.2835 0.2125 0.5454 0.1392 0.5472 0.3523 0.0281 0.0761 0.3466 0.2488 0.0669 0.1949 0.6675 0.3839 0.6477 0.0473 0.0782 0.7651 0.0038 0.9158 0.4291 0.9509 0.4207 0.0638 0.4440 0.4376 0.2680 0.7316 0.1104 0.0697 0.9138 0.8651 0.4510 0.5774 0.4748 0.1017 0.3210 0.1325 0.4478 0.1331 0.1650 0.9250 0.8232 0.7807 0.9316 0.0379 0.5812 0.6371 0.0003 0.1510 0.7797 0.3697 0.1407 0.0685 0.1701 0.9645 0.8110 0.7891 0.0724 0.5226 0.5626 0.1376 0.1683 0.6190 0.8367 0.7184 0.1962 0.5047 0.3737 0.6859 0.2957 0.5869 0.3297 0.5181 0.4639 0.8835 0.7569 0.7612 0.2986 0.3689 0.0233 0.2355 A(:,:,3) = 0.8343 0.3276 0.7903 0.1419 0.3574 0.5691 0.7271 0.9662 0.4537 0.9456 0.8164 0.8488 0.5330 0.8833 0.2792 0.1339 0.8601 0.0708 0.1541 0.0025 0.2354 0.7025 0.3541 0.5137 0.0674 0.8190 0.0954 0.0540 0.5976 0.2894 0.6983 0.8874 0.5857 0.1623 0.5114 0.7782 0.7195 0.2250 0.3673 0.3873 0.6482 0.4351 0.3189 0.0460 0.2372 0 0.7287 0.9922 0.8652 0.3613 0.3419 0.5438 0.4793 0.4557 0.3569 0.6160 0.7794 0.4519 0.5192 0.8023 0.1770 0.8165 0.2791 0.8134 0.8857 0.9765 0.4628 0.3414 0.8402 0.0913 0.3102 0.2142 0.0678 0.6363 0.8668 0.0629 0.5991 0.4120 0.7273 0.6504 0.0015 0.2755 0.7960 0.7772 0.0687 0.5218 0.1422 0.9258 0.1984 0.7513 0.1991 0.8150 0.6030 0.5209 0.7306 0.0065 0.8075 0.5218 0.4995 0.7862 A(:,:,4) = 0.5244 0.2404 0.4173 0.2408 0.8551 0.6098 0.8854 0.2955 0.4618 0.0222 0.7097 0.6333 0.9574 0.1884 0.9026 0.6443 0.2909 0.0726 0.9152 0.3884 0.1601 0.3410 0.0744 0.0850 0.9472 0.2506 0.1764 0.8645 0.5932 0.9825 0.6393 0.7074 0.5132 0.1413 0.8534 0.0750 0.9720 0.1124 0.9000 0.5818 0.3954 0.8820 0.9843 0.9321 0.9258 0.7064 0.0569 0.9686 0.8423 0.4913 0.2542 0.2372 0.3891 0.9484 0.8264 0.2464 0.4458 0.0258 0.2805 0.9435 0.8154 0.5053 0.7050 0.1139 0.5702 0.0018 0.6063 0.5914 0.5917 0.3962 0.7462 0.8802 0.0012 0.5085 0.1981 0.4708 0.5893 0.8147 0.2515 0.5855 0.8144 0.0365 0.1702 0.1392 0.4582 0.9501 0.2206 0.4260 0.0820 0.2751 0.2995 0.3040 0.2057 0.8566 0.9312 0.6678 0.3172 0.5576 0.3646 0.0500 A(:,:,5) = 0.4409 0.3426 0.2970 0.3695 0.4763 0.5070 0.7798 0.1095 0.2987 0.8178 0.6966 0.7563 0.2114 0.4956 0.6014 0.7359 0.3167 0.6633 0.8033 0.6829 0.3417 0.3978 0.1130 0.7039 0.3661 0.6248 0.3651 0.8165 0.9825 0.5051 0.4262 0.3186 0.5284 0.8548 0.5598 0.8702 0.9523 0.9988 0.5943 0.1112 0.1089 0.7348 0.7846 0.8039 0.0558 0.4283 0.1759 0.1551 0.0349 0.8709 0.9031 0.0819 0.8325 0.2477 0.4969 0.4995 0.1814 0.7411 0.8261 0.9925 0.5536 0.2051 0.7031 0.8976 0.7650 0.5238 0.3443 0.2420 0.0310 0.7886 0.3799 0.5808 0.2703 0.0243 0.0295 0.6998 0.5581 0.0672 0.8933 0.9783 0.7379 0.4227 0.8845 0.5208 0.7500 0.2581 0.7177 0.5924 0.1527 0.4610 0.1224 0.0271 0.2061 0.4017 0.3626 0.7403 0.5095 0.9385 0.1442 0.9017 A(:,:,6) = 0.5683 0.3286 0.0430 0.9812 0.6612 0.2518 0.4451 0.2896 0.2652 0.0426 0.9952 0.1178 0.5413 0.3356 0.3476 0.3612 0.2400 0.2521 0.2044 0.5479 0.5756 0.8604 0.4017 0.2104 0.4766 0.6769 0.2768 0.3874 0.8305 0.0525 0.5352 0.4789 0.6883 0.7170 0.5766 0.3247 0.1276 0.5782 0.9225 0.8238 0.8311 0.1772 0.8149 0.5174 0.8136 0.2279 0.4355 0.5380 0.4999 0.7656 0.3375 0.4847 0.6993 0.9753 0.0391 0.8542 0.9667 0.8586 0.2310 0.5224 0.4721 0.7311 0.5676 0.9841 0.9757 0.7208 0.3698 0.1711 0.7545 0.5334 0.0317 0.0342 0.4864 0.5546 0.5401 0.2074 0.2971 0.4578 0.6693 0.5331 0.3568 0.5637 0.2808 0.7815 0.6328 0.3219 0.0564 0.2300 0.9804 0.2129 0.9294 0.0422 0.4346 0.7564 0.0906 0.9920 0.5519 0.7767 0.5725 0.4884 A(:,:,7) = 0.4323 0.8177 0.8704 0.1271 0.5558 0.4595 0.8666 0.3888 0.4243 0.1760 0.6458 0.2641 0.3664 0.6744 0.1284 0.3217 0.4968 0.5086 0.4255 0.3773 0.1531 0.5685 0.9545 0.8632 0.6986 0.7791 0.4096 0.9875 0.8514 0.8915 0.5486 0.7224 0.2279 0.6613 0.6731 0.9737 0.5185 0.4831 0.8769 0.4587 0.5259 0.6375 0.2263 0.1024 0.7028 0.0899 0.1548 0.0614 0.7768 0.2081 0.0413 0.4557 0.1092 0.1256 0.1993 0.8622 0.4155 0.2118 0.3795 0.8067 0.6759 0.0744 0.0790 0.4841 0.4970 0.6517 0.2941 0.8584 0.8141 0.2987 0.1395 0.9323 0.4490 0.7938 0.6925 0.1094 0.0409 0.7488 0.8230 0.4030 0.6248 0.5161 0.1694 0.5230 0.4687 0.1120 0.3746 0.2356 0.8593 0.7244 0.7427 0.2672 0.9020 0.9840 0.0226 0.7012 0.5634 0.6496 0.7963 0.3587 A(:,:,8) = 0.6553 0.2256 0.7128 0.7466 0.3215 0.4930 0.5607 0.0879 0.6913 0.9659 0.2800 0.3429 0.8325 0.3159 0.7755 0.7801 0.9115 0.8856 0.8515 0.8962 0.5594 0.3681 0.4364 0.3975 0.4010 0.9900 0.4735 0.7349 0.8102 0.0878 0.1882 0.8164 0.7186 0.5489 0.2833 0.3255 0.5271 0.8913 0.3078 0.8598 0.5469 0.9039 0.6458 0.7900 0.2321 0.8048 0.5992 0.2256 0.5781 0.9048 0.2895 0.8063 0.7501 0.2932 0.2064 0.0786 0.4557 0.5543 0.2298 0.7294 0.7113 0.6808 0.7134 0.8011 0.4282 0.2198 0.3584 0.6632 0.8108 0.6064 0.1950 0.6707 0.3365 0.9693 0.4532 0.6949 0.2713 0.3166 0.4183 0.0824 0.9683 0.0947 0.2982 0.5644 0.5174 0.5890 0.4881 0.6666 0.0910 0.5184 0.8901 0.4365 0.3496 0.4830 0.4285 0.2216 0.1827 0.9228 0.4972 0.6099 A(:,:,9) = 0.0728 0.3958 0.5233 0.5283 0.4131 0.2488 0.7038 0.8679 0.7390 0.6607 0.1532 0.3912 0.9181 0.8985 0.8354 0.9303 0.7745 0.5981 0.2160 0.6593 0.3143 0.2119 0.0419 0.4017 0.1978 0.9774 0.4478 0.1527 0.1698 0.7445 0.8207 0.1935 0.6438 0.7204 0.2254 0.5256 0.1844 0.3176 0.1286 0.5365 0.5367 0.1661 0.8652 0.1162 0.4253 0.5208 0.5550 0.9637 0.9843 0.7498 0.0446 0.7039 0.2419 0.4273 0.2663 0.9971 0.8203 0.0789 0.4622 0.6434 0.2037 0.2585 0.5879 0.8878 0.0787 0.2538 0.9215 0.0955 0.0779 0.6102 0.0446 0.5328 0.8790 0.8676 0.7914 0.1160 0.9212 0.5903 0.0977 0.1124 0.0006 0.3486 0.5548 0.6424 0.4290 0.6427 0.1482 0.2389 0.8835 0.3686 0.9560 0.1699 0.3405 0.1344 0.6513 0.4798 0.1243 0.1043 0.3633 0.5242 A(:,:,10) = 0.8351 0.4949 0.8300 0.5897 0.9931 0.3493 0.8493 0.8519 0.4615 0.1067 0.2350 0.9853 0.2178 0.3561 0.4721 0.0452 0.6888 0.2106 0.0646 0.5105 0.9893 0.0014 0.2950 0.5074 0.6592 0.7859 0.8865 0.6068 0.0761 0.7933 0.9356 0.2867 0.8191 0.2942 0.9842 0.1434 0.5520 0.6290 0.0733 0.5522 0.6732 0.6729 0.9810 0.7763 0.4875 0.9947 0.1441 0.0062 0.5250 0.4641 0.8772 0.6585 0.0189 0.4983 0.5960 0.4548 0.7352 0.1827 0.3328 0.6727 0.8365 0.7307 0.9712 0.1255 0.4045 0.4469 0.8679 0.9591 0.8699 0.2458 0.1669 0.4473 0.8925 0.4737 0.7012 0.8245 ...

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

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