Cody

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

Solution 279487

Submitted on 12 Jul 2013 by Dennis J
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
%% test 1 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
%% test 2 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
%% test 3 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
%% test 4 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
%% test 5 with a multidimensional array 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.4242 0.6644 0.9720 0.8551 0.1994 0.4856 0.4196 0.6604 0.5917 0.6575 0.3014 0.9452 0.6816 0.6451 0.2347 0.7519 0.0003 0.0484 0.5685 0.9050 0.8682 0.6776 0.7223 0 0.1462 0.2239 0.7393 0.3688 0.3724 0.7276 0.5231 0.7480 0.2932 0.7137 0.7234 0.1206 0.2669 0.9914 0.7038 0.6554 0.4736 0.6570 0.6924 0.1174 0.2311 0.4763 0.4899 0.5366 0.8629 0.7774 0.6855 0.7253 0.6752 0.1804 0.7314 0.8213 0.7827 0.9008 0.4361 0.2590 0.8737 0.3549 0.1404 0.3034 0.3106 0.6706 0.2865 0.2974 0.2659 0.9159 0.0442 0.3411 0.3294 0.2095 0.0979 0.7232 0.1507 0.0756 0.3482 0.8236 0.4815 0.3181 0.6364 0.7129 0.4732 0.2909 0.2318 0.7312 0.3086 0.6876 0.8357 0.4356 0.6182 0.2387 0.1345 0.5778 0.4511 0.5745 0.1652 0.6966 A(:,:,2) = 0.7944 0 0.5439 0.1643 0.9815 0.3632 0.9800 0.2283 0.7850 0.7674 0.3049 0.1942 0.5383 0.0090 0.4590 0.1034 0.9752 0.8034 0.3191 0.8563 0.3833 0.8918 0.2664 0.6350 0.8874 0.0731 0.0915 0.6882 0.7535 0.0416 0.7379 0.7191 0.6862 0.5225 0.2662 0.0994 0.5352 0.7781 0.8365 0.9936 0.1930 0.2643 0.4119 0.7311 0.4406 0.7212 0.8111 0.6292 0.0552 0.7523 0.1519 0.8367 0.2365 0.6310 0.7430 0.7564 0.9297 0.1771 0.6543 0.5147 0.4255 0.2207 0.5874 0.4682 0.5127 0.1671 0.2545 0.5953 0.0943 0.2168 0.5860 0.7754 0.2590 0.6969 0.9190 0.4237 0.3978 0.0638 0.2505 0.0970 0.5353 0.3001 0.5808 0.8173 0.1773 0.8497 0.4513 0.3526 0.8155 0.7945 0.9560 0.0338 0.3861 0.6835 0.8651 0.3779 0.7350 0.9937 0.3993 0.7187 A(:,:,3) = 0.5945 0.3807 0.0535 0.2047 0.8071 0.2444 0.2622 0.0893 0.7953 0.0036 0.5214 0.7163 0.6280 0.8468 0.5905 0.9310 0.2245 0.3573 0.4604 0.9352 0.7233 0.8773 0.8674 0.9238 0.1795 0.1226 0.2572 0.3999 0.2444 0.9025 0.3739 0.0278 0.9319 0.6538 0.1094 0.9006 0.1506 0.1697 0.0423 0.6668 0.9306 0.2933 0.7594 0.4692 0.3648 0 0.6005 0.1321 0.5135 0.2485 0.3044 0.0840 0.1976 0.5473 0.2084 0.6795 0.3127 0.9486 0.8015 0.7185 0.5889 0.1230 0.0450 0.1820 0.4622 0.7828 0.4638 0.9150 0.1353 0.2941 0.6126 0.7537 0.0624 0.8387 0.7632 0.7489 0.7521 0.4038 0.6207 0.2450 0.4007 0.4775 0.0065 0.5675 0.0670 0.9244 0.3536 0.4950 0.1517 0.2854 0.4145 0.9580 0.1136 0.7508 0.6378 0.1695 0.6294 0.9755 0.0353 0.8981 A(:,:,4) = 0.5097 0.0612 0.1182 0.2618 0.5911 0.6011 0.1504 0.2796 0.3533 0.1359 0.6723 0.8027 0.6946 0.6729 0.4847 0.2733 0.1380 0.0711 0.1367 0.5305 0.8341 0.0712 0.3337 0.2876 0.6276 0.7375 0.4976 0.2766 0.8678 0.5389 0.2173 0.8113 0.8954 0.7298 0.4462 0.3024 0.5037 0.4642 0.9635 0.6266 0.2838 0.2498 0.1504 0.7595 0.0133 0.4571 0.2988 0.0436 0.2070 0.4620 0.3831 0.1036 0.9864 0.2353 0.2853 0.3076 0.9610 0.4656 0.3863 0.9043 0.9394 0.7647 0.5716 0.8057 0.6793 0.5253 0.6419 0.6689 0.9472 0.2871 0.9190 0.7196 0.0268 0.6889 0.5895 0.9041 0.4269 0.4181 0.7234 0.6283 0.8428 0.2967 0.1906 0.4685 0.3325 0.7604 0.4034 0.1358 0.8727 0.7968 0.0087 0.7301 0.6472 0.0717 0.3502 0.2764 0.4852 0.0008 0.1443 0.0165 A(:,:,5) = 0.9525 0.5999 0.3159 0.7768 0.2522 0.9149 0.7999 0.3872 0.6173 0.7909 0.0280 0.3942 0.3788 0.4441 0.8387 0.3310 0.1990 0.7605 0.7627 0.6539 0.4950 0.3785 0.5310 0.2909 0.4703 0.4240 0.2497 0.7290 0.2482 0.7139 0.6081 0.6956 0.7388 0.1373 0.6839 0.3986 0.8328 0.1230 0.9151 0.6333 0.0155 0.7137 0.5874 0.0133 0.2215 0.6275 0.4493 0.5660 0.3284 0.9829 0.0400 0.8828 0.6318 0.8295 0.9339 0.8311 0.3952 0.4394 0.9717 0.1170 0.5380 0.1743 0.2674 0.3662 0.0830 0.1757 0.0132 0.9537 0.4457 0.4947 0.7308 0.4347 0.0299 0.3504 0.3319 0.1318 0.0263 0.7786 0.6426 0.6625 0.9989 0.2880 0.5665 0.1346 0.7975 0.4536 0.7768 0.5940 0.9658 0.0237 0.7339 0.1769 0.7553 0.9287 0.1400 0.4661 0.8199 0.4334 0.3855 0.6499 A(:,:,6) = 0.7927 0.5017 0.9177 0.1339 0.2604 0.7817 0.4834 0.6495 0.9456 0.2474 0.2521 0.0343 0.5972 0.2529 0.6336 0.7344 0.5920 0.4941 0.4173 0.2901 0.2433 0.4438 0.0657 0.1311 0.7046 0.1936 0.2127 0.3712 0.1318 0.6054 0.7017 0.1511 0.4175 0.1116 0.6346 0.3623 0.8060 0.9170 0.8239 0.7917 0.8968 0.9495 0.8750 0.2947 0.7840 0.3613 0.8413 0.6639 0.1552 0.2516 0.3544 0.0317 0.1609 0.1398 0.6434 0.9195 0.4432 0.1604 0.6210 0.3982 0.9336 0.2491 0.6977 0.4682 0.4067 0.9890 0.9673 0.7002 0.9349 0.4161 0.7319 0.0641 0.4516 0.3821 0.3446 0.7020 0.3477 0.0720 0.1700 0.2897 0.0304 0.6642 0.3830 0.1689 0.4243 0.2276 0.3626 0.6185 0.9614 0.0466 0.1480 0.0945 0.0098 0.3369 0.2193 0.0630 0.9992 0.8471 0.8600 0.6916 A(:,:,7) = 0.7841 0.3565 0.0073 0.8501 0.7257 0.1287 0.2945 0.4005 0.3847 0.1553 0.6000 0.3102 0.9458 0.3897 0.5820 0.7785 0.2945 0.5237 0.9905 0.5381 0.7380 0.5536 0.1635 0.7546 0.1230 0.9702 0.9488 0.3432 0.5201 0.2578 0.2892 0.5774 0.3128 0.2068 0.7040 0.5286 0.8810 0.9011 0.0051 0.4703 0.0719 0.6541 0.8982 0.4302 0.7387 0.8977 0.2888 0.2127 0.6119 0.5110 0.8728 0.3174 0.3814 0.9661 0.3689 0.7487 0.1811 0.2745 0.9154 0.4152 0.6625 0.5571 0.8619 0.8127 0.4633 0.9548 0.4848 0.0525 0.2119 0.5048 0.2631 0.7861 0.2832 0.6967 0.5623 0.9565 0.6705 0.3392 0.8976 0.1979 0.9071 0.5264 0.2689 0.1507 0.6328 0.8886 0.6758 0.5751 0.7768 0.4879 0.1217 0.5383 0.9405 0.8656 0.2796 0.9920 0.6292 0.2078 0.7204 0.4048 A(:,:,8) = 0.5384 0.3628 0.2717 0.3748 0.1286 0.6336 0.2877 0.3879 0.9448 0.1685 0.4515 0.8783 0.3032 0.6760 0.4753 0.4576 0.0742 0.6188 0.7726 0.4734 0.7868 0.5767 0.3532 0.2481 0.4158 0.7103 0.0063 0.4199 0.5109 0.6466 0.3026 0.5994 0.1298 0.9335 0.4957 0.0289 0.3013 0.1830 0.1289 0.0282 0.6693 0.2743 0.8130 0.7199 0.2889 0.9895 0.3433 0.4435 0.8380 0.8939 0.1669 0.8355 0.7794 0.3203 0.8797 0.6011 0.7166 0.9739 0.8015 0.9747 0.2984 0.2505 0.4676 0.4864 0.0382 0.8757 0.6710 0.2085 0.1537 0.0712 0.1758 0.2236 0.2139 0.4862 0.9485 0.0771 0.9402 0.6547 0.0445 0.9403 0.3759 0.0976 0.9918 0.3536 0.2629 0.4944 0.2279 0.4549 0.9170 0.7147 0.1188 0.3920 0.1874 0.7599 0.0195 0.1113 0.2832 0.5897 0.6193 0.1948 A(:,:,9) = 0.8967 0.3374 0.5785 0.8029 0.7441 0.6351 0.4796 0.8377 0.4202 0.2184 0.3391 0.9352 0.0215 0.5591 0.3214 0.8117 0.0051 0.8825 0.1757 0.2243 0.7958 0.7341 0.0305 0.1873 0.7321 0.3816 0.3594 0.0065 0.8553 0.5967 0.4400 0.6122 0.5032 0.0469 0.8548 0.8119 0.7529 0.7589 0.2589 0.8525 0.3006 0.7306 0.0082 0.0546 0.0306 0.7963 0.8688 0.0639 0.1049 0.8033 0.3617 0.4621 0.5591 0.2113 0.2253 0.1480 0.2525 0.1438 0.1145 0.0169 0.0542 0.4344 0.3002 0.1784 0.6812 0.9166 0.3510 0.3893 0.2079 0.9999 0.2926 0.9814 0.6888 0.5593 0.2404 0.5437 0.3217 0.9598 0.1148 0.9578 0.4322 0.1963 0.7726 0.8862 0.4658 0.3332 0.0560 0.6264 0.0017 0.4081 0.9457 0.5755 0.8541 0.9563 0.6629 0.3668 0.5888 0.0721 0.4061 0.1387 A(:,:,10) = 0.6091 0.0431 0.0344 0.1514 0.8426 0.8930 0.8737 0.7365 0.6448 0.1498 0.3331 0.0230 0.0267 0.6722 0.9724 0.4338 0.2461 0.1530 0.8601 0.1782 0.2291 0.0786 0.5960 0.0679 0.1952 0.0859 0.0549 0.2268 0.9289 0.3386 0.7698 0.2433 0.2439 0.9003 0.1263 0.1991 0.4417 0.2886 0.3362 0.9098 0.9897 0.7350 0.5470 0.2085 0.7276 0.5696 0.0444 0.3131 0.5439 0.9224 0.4976 0.9715 0.0121 0.0581 0.3012 0.3158 0.8480 0.1961 0.7439 0.4730 0.7224 0.1504 0.8206 0.4458 0.4469 0.4013 0.2123 0.1828 0.5012 0.6791 0.3501 0.9326 0.3889 0.9321 0.0720 0.5899 0.6939 0.9876 0.0306 ...

6   Pass
%% test 6 repmat ! 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 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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 Column 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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
%% test 7 magic! 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
%% test 8 floating (maybe people will work with string recognition) A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

A = 13.3000