Cody

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

Solution 859408

Submitted on 30 Mar 2016 by HH
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) = Columns 1 through 9 0.1007 0.6152 0.1708 0.1325 0.7163 0.5131 0.1309 0.8787 0.4964 0.5184 0.6683 0.8892 0.9002 0.4791 0.0013 0.7983 0.8475 0.7708 0.7339 0.7762 0.6250 0 0.5606 0.2979 0.3309 0.2757 0.2756 0.3279 0.7197 0.3473 0.7496 0.9138 0.6149 0.7006 0.5314 0.3247 0.0765 0.4710 0.9007 0.6640 0.7609 0.3380 0.3972 0.8336 0.9624 0.1314 0.4242 0.7758 0.2048 0.6832 0.3724 0.4564 0.0186 0.5024 0.7072 0.0612 0.2239 0.5757 0.6392 0.6556 0.7114 0.5361 0.4670 0.6749 0.9724 0.2188 0.4495 0.6962 0.9631 0.1220 0.6216 0.3914 0.2735 0.9560 0.4943 0.0625 0.6547 0.7380 0.8509 0.1985 0.4980 0.7726 0.4718 0.8129 0.6009 0.0420 0.2221 0.5997 0.5459 0.7123 Column 10 0.7701 0.8241 0.5273 0.1827 0.2653 0.1304 0.8776 0.7629 0.5322 0.9528 A(:,:,2) = Columns 1 through 9 0.8118 0 0.6151 0.3135 0.3131 0.7952 0.4861 0.4194 0.4742 0.6311 0.0962 0.0887 0.8353 0.9843 0.9195 0.8325 0.8883 0.4097 0.1487 0.7482 0.7681 0.7441 0.0020 0.1316 0.3726 0.3076 0.0544 0.0425 0.4518 0.9815 0.7086 0.5081 0.2803 0.3575 0.9002 0.2688 0.6827 0.6578 0.2136 0.4550 0.6205 0.0186 0.7732 0.5492 0.2619 0.5935 0.5462 0.0383 0.2951 0.5340 0.5541 0.8926 0.2713 0.6576 0.7298 0.0292 0.8806 0.9451 0.9441 0.2489 0.1762 0.9151 0.2847 0.8216 0.0714 0.9129 0.6830 0.7237 0.0355 0.1290 0.3298 0.9138 0.1018 0.8031 0.8122 0.8899 0.1068 0.7728 0.2203 0.3688 0.6393 0.2809 0.6549 0.4870 0.4736 0.7043 0.7061 0.7598 0.0815 0.5610 Column 10 0.0333 0.5266 0.0300 0.5453 0.3701 0.9096 0.2376 0.4545 0.0552 0.2312 A(:,:,3) = Columns 1 through 9 0.5233 0.1633 0.0185 0.9916 0.6256 0.3196 0.4730 0.7794 0.1735 0.5435 0.5856 0.9666 0.0126 0.0857 0.9695 0.3139 0.3857 0.9691 0.1848 0.7126 0.7729 0.3322 0.6685 0.7066 0.9358 0.8469 0.9037 0.9480 0.1520 0.2702 0.7660 0.3992 0.1441 0.7872 0.8710 0.6312 0.8865 0.2923 0.8235 0.3063 0.6424 0 0.4943 0.1816 0.2155 0.2510 0.4115 0.7311 0.2445 0.9541 0.4379 0.2635 0.8355 0.6157 0.1181 0.9909 0.4455 0.9240 0.9459 0.0966 0.9413 0.5906 0.0671 0.2335 0.1204 0.8451 0.7399 0.8183 0.7555 0.2051 0.2867 0.9400 0.1257 0.6624 0.6436 0.0135 0.9570 0.9197 0.4314 0.5354 0.7894 0.1862 0.7979 0.4727 0.5368 0.3420 0.1148 0.7803 0.6966 0.8608 Column 10 0.1047 0.5895 0.3375 0.8205 0.9922 0.6581 0.5175 0.3394 0.8735 0.9968 A(:,:,4) = Columns 1 through 9 0.0942 0.9374 0.4209 0.3449 0.6375 0.4257 0.5988 0.5755 0.0965 0.3166 0.0194 0.8017 0.1820 0.1538 0.1415 0.6255 0.2951 0.9916 0.7314 0.0374 0.4529 0.1986 0.2511 0.1585 0.6155 0.1318 0.9667 0.7519 0.0629 0.5603 0.6102 0.0029 0.1011 0.0027 0.5121 0.9446 0.2347 0.7844 0.5029 0.7190 0.2685 0.2263 0.0114 0.7161 0.6167 0.8406 0.9464 0.3282 0.3052 0.8072 0.6770 0.0651 0.9062 0.8867 0.2773 0.0940 0.9530 0.6142 0.1958 0.1842 0.8656 0.0442 0.4324 0.7907 0.7863 0.9868 0.1070 0.4947 0.0386 0.6587 0.9313 0.1533 0.9348 0.2113 0.6966 0.7017 0.1122 0.1126 0.0749 0.2278 0.6117 0.2429 0.9110 0.0040 0.9986 0.2682 0.3090 0.7134 0.9704 0.2168 Column 10 0.6654 0.5062 0.2148 0.4119 0.2952 0.5328 0.4579 0.8468 0.1689 0.9212 A(:,:,5) = Columns 1 through 9 0.5912 0.0090 0.8986 0.8781 0.9645 0.0044 0.1586 0.0019 0.0683 0.4037 0.2884 0.7651 0.8537 0.7179 0.5049 0.1505 0.9070 0.4738 0.9088 0.9215 0.7220 0.7992 0.7082 0.9170 0.2821 0.4848 0.8427 0.1904 0.1910 0.3979 0.5073 0.7815 0.4514 0.8914 0.4113 0.8005 0.1116 0.4654 0.3240 0.5383 0.7137 0.1317 0.0763 0.7143 0.5334 0.6726 0.1581 0.8111 0.6411 0.5991 0.5106 0.2905 0.3213 0.8389 0.4980 0.4995 0.2368 0.9065 0.3736 0.5711 0.4163 0.3151 0.8621 0.4167 0.1782 0.1490 0.1609 0.7380 0.7543 0.7338 0.0416 0.2642 0.1761 0.6086 0.4042 0.6251 0.8064 0.7723 0.5657 0.2480 0.4474 0.5046 0.6307 0.4974 0.9819 0.6549 0.8443 0.5574 0.2789 0.8380 Column 10 0.2548 0.5501 0.5150 0.2103 0.5188 0.1526 0.7468 0.1459 0.0463 0.6368 A(:,:,6) = Columns 1 through 9 0.8314 0.7563 0.9904 0.5472 0.8020 0.9621 0.8320 0.2876 0.6942 0.3640 0.4637 0.5194 0.7537 0.3576 0.0272 0.0338 0.2887 0.5076 0.2145 0.9985 0.3258 0.2953 0.1207 0.1429 0.1973 0.0568 0.2188 0.6310 0.9382 0.6711 0.7414 0.2931 0.1012 0.5356 0.8457 0.8912 0.7714 0.5892 0.8976 0.2307 0.6990 0.5460 0.4276 0.3662 0.7423 0.1441 0.1148 0.0309 0.6283 0.1939 0.2178 0.4131 0.9719 0.5562 0.6768 0.3355 0.8909 0.8656 0.3248 0.7585 0.4116 0.1254 0.7240 0.7116 0.2352 0.0960 0.6482 0.9807 0.9015 0.9533 0.8765 0.5196 0.9050 0.7893 0.8740 0.4354 0.1929 0.2873 0.9396 0.3859 0.1758 0.0214 0.2256 0.2545 0.1623 0.5762 0.2392 0.4219 0.4236 0.6226 Column 10 0.4324 0.0402 0.5290 0.4817 0.8309 0.3803 0.7782 0.4792 0.7011 0.4536 A(:,:,7) = Columns 1 through 9 0.4868 0.6994 0.5550 0.0231 0.3431 0.6610 0.8622 0.8255 0.0004 0.0806 0.5006 0.3691 0.6127 0.8958 0.2413 0.1838 0.2450 0.4044 0.3003 0.8118 0.7431 0.6824 0.6853 0.8757 0.8755 0.5369 0.5734 0.9736 0.4853 0.0018 0.9425 0.9765 0.7892 0.7052 0.4200 0.1266 0.7929 0.5821 0.4580 0.6589 0.6166 0.4082 0.2005 0.5893 0.6671 0.3876 0.1650 0.3220 0.6940 0.0473 0.7959 0.5040 0.1351 0.8391 0.0709 0.9177 0.0255 0.7247 0.5107 0.4942 0.9763 0.3762 0.1560 0.6814 0.7026 0.9517 0.7491 0.3142 0.1947 0.5870 0.1393 0.8176 0.1244 0.3022 0.2430 0.8262 0.0987 0.2279 0.9772 0.4889 0.6424 0.6626 0.6356 0.3350 0.4160 0.3264 0.1575 0.5048 0.1161 0.9433 Column 10 0.4983 0.6229 0.5308 0.8246 0.1925 0.9985 0.3698 0.6986 0.9110 0.0051 A(:,:,8) = Columns 1 through 9 0.8406 0.5501 0.5014 0.5966 0.4838 0.2647 0.4769 0.6186 0.8850 0.0724 0.9508 0.3162 0.6085 0.8687 0.1223 0.4325 0.2985 0.4341 0.6009 0.8793 0.6323 0.7455 0.1125 0.8463 0.8357 0.1589 0.6792 0.5097 0.9330 0.0213 0.8464 0.8267 0.4299 0.5376 0.1210 0.6333 0.0760 0.0787 0.3051 0.4763 0.9148 0.2638 0.0325 0.5510 0.9315 0.7216 0.9745 0.6178 0.1754 0.9571 0.3015 0.2769 0.9976 0.6597 0.7539 0.6661 0.1364 0.5782 0.5060 0.9079 0.3768 0.6939 0.7604 0.8400 0.4368 0.3489 0.0645 0.3204 0.9667 0.0611 0.9086 0.4376 0.6553 0.3701 0.8189 0.2622 0.6037 0.1125 0.2581 0.9661 0.6179 0.9615 0.5501 0.1026 0.7416 0.3920 0.8256 0.6614 0.6553 0.3490 Column 10 0.3226 0.3803 0.6460 0.0348 0.5131 0.6097 0.2381 0.1505 0.7453 0.8419 A(:,:,9) = Columns 1 through 9 0.5751 0.5539 0.3366 0.5470 0.3065 0.0141 0.0901 0.4572 0.0534 0.8873 0.1195 0.5751 0.2694 0.5925 0.0156 0.4640 0.5273 0.0346 0.3451 0.4747 0.7042 0.2184 0.9551 0.0054 0.7308 0.4236 0.9054 0.4183 0.0957 0.0528 0.9662 0.4841 0.6914 0.0158 0.5282 0.8528 0.0563 0.6965 0.0096 0.9618 0.1412 0.0146 0.7137 0.4110 0.5848 0.6683 0.6162 0.7516 0.2069 0.2332 0.1015 0.0069 0.6519 0.1592 0.5132 0.1478 0.3095 0.1145 0.4138 0.8115 0.3867 0.3252 0.8814 0.9883 0.8483 0.5651 0.0556 0.2817 0.5585 0.3233 0.2129 0.8846 0.2764 0.8936 0.4921 0.9622 0.3522 0.3063 0.0374 0.6585 0.6856 0.9070 0.3959 0.9673 0.3052 0.2054 0.8418 0.4183 0.6380 0.5998 Column 10 0.3939 0.5660 0.2973 0.2218 0.2379 0.9909 0.5518 0.5535 0.9871 0.8292 A(:,:,10) = Columns 1 through 9 0.8315 0.2630 0.8975 0.7492 0.8326 0.7688 0.6478 0.7669 0.8269 0.1149 0.8038 0.9334 0.0546 0.1961 0.2200 0.3286 0.4494 0.2825 0.4961 0.5082 0.8560 0.9108 0.9807 0.8821 0.1338 0.2417 0.6672 0.8792 0.2454 0.5769 0.9195 0.7322 ...

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 = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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

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