Cody

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

Solution 3412978

Submitted on 26 Oct 2020 by Knox Peterson
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')

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

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

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

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

B(:,:,1) = 0.8995 0.2807 0.2488 0.6919 0.8276 0.8424 0.9209 0.5242 0.9774 0.5288 0.8584 0.8695 0.8453 0.1945 0.4286 0.0043 0.8025 0.9100 0.2882 0.1814 0.4966 0.1980 0.4725 0 0.7509 0.0865 0.2212 0.0660 0.4394 0.1918 0.5178 0.2311 0.2860 0.8025 0.4338 0.0690 0.9391 0.9229 0.1557 0.0924 0.5095 0.3744 0.3519 0.0537 0.1315 0.3428 0.1749 0.4230 0.9735 0.3260 0.8931 0.3290 0.3175 0.4863 0.0338 0.7820 0.8361 0.7462 0.4550 0.1774 0.0186 0.1306 0.3319 0.8118 0.1366 0.6225 0.0067 0.3850 0.3757 0.7213 0.5488 0.8290 0.5493 0.2255 0.2500 0.3920 0.7877 0.1746 0.9580 0.9479 0.6051 0.8884 0.0308 0.6511 0.3443 0.2513 0.9604 0.4093 0.4842 0.9249 0.0602 0.0379 0.2062 0.9427 0.4606 0.0581 0.9982 0.8219 0.6704 0.7229 B(:,:,2) = 0.8301 0 0.7069 0.4848 0.8491 0.1789 0.2834 0.3712 0.5592 0.2871 0.5219 0.2797 0.1197 0.3067 0.3003 0.3886 0.9794 0.9449 0.1531 0.6596 0.0741 0.5104 0.9699 0.1500 0.7477 0.2093 0.5882 0.4434 0.1550 0.5941 0.5527 0.3444 0.8435 0.4812 0.0276 0.3487 0.9313 0.0943 0.0670 0.6341 0.6497 0.7947 0.1709 0.8281 0.7544 0.6180 0.3632 0.8750 0.8955 0.6517 0.8392 0.3011 0.5525 0.3120 0.9847 0.3262 0.0153 0.8011 0.6251 0.1400 0.8825 0.5448 0.9505 0.5660 0.3154 0.9900 0.6012 0.6058 0.4530 0.0106 0.5719 0.1654 0.1523 0.6308 0.2053 0.8294 0.3895 0.9672 0.4072 0.3696 0.8017 0.4235 0.6483 0.3270 0.8517 0.2471 0.1087 0.5209 0.9350 0.9255 0.7962 0.5223 0.5302 0.6445 0.2329 0.3074 0.8853 0.5041 0.1391 0.1856 B(:,:,3) = 0.4854 0.7121 0.2968 0.0646 0.9378 0.6963 0.7158 0.5913 0.8369 0.9792 0.5046 0.3091 0.0896 0.1650 0.6239 0.0564 0.5240 0.8675 0.1376 0.8913 0.3174 0.0262 0.3317 0.7176 0.9844 0.0264 0.5362 0.7058 0.2393 0.8005 0.6578 0.1497 0.8582 0.3816 0.2211 0.9434 0.5190 0.2613 0.6497 0.0874 0.4114 0.5119 0.7452 0.6444 0.7566 0 0.4482 0.0571 0.9224 0.3837 0.8190 0.2798 0.4630 0.9693 0.7806 0.6757 0.2328 0.7138 0.2124 0.4605 0.9699 0.4807 0.1283 0.9954 0.6996 0.1625 0.1862 0.0096 0.8346 0.1754 0.5861 0.3314 0.6403 0.1410 0.3577 0.8734 0.7674 0.1413 0.0969 0.1833 0.3440 0.7828 0.0089 0.9307 0.2908 0.7914 0.5212 0.6947 0.6502 0.2661 0.9108 0.5711 0.7680 0.9351 0.1811 0.0949 0.1298 0.0523 0.7796 0.0287 B(:,:,4) = 0.6538 0.0485 0.6442 0.5086 0.0714 0.0524 0.2619 0.7109 0.0448 0.8968 0.8207 0.0335 0.6349 0.9797 0.1566 0.1590 0.9087 0.5411 0.3685 0.8013 0.5255 0.3607 0.2501 0.9141 0.0291 0.9251 0.9524 0.1456 0.1883 0.6298 0.8651 0.9673 0.6161 0.7327 0.9242 0.3528 0.6761 0.7485 0.5884 0.3589 0.3764 0.6158 0.7373 0.9033 0.5698 0.4151 0.7390 0.7527 0.9948 0.9477 0.6739 0.9783 0.3680 0.2815 0.6405 0.9289 0.5348 0.7468 0.8743 0.6113 0.7213 0.6049 0.8800 0.7828 0.2789 0.9413 0.9878 0.0951 0.0711 0.5691 0.9111 0.3662 0.5746 0.6410 0.4097 0.1498 0.2005 0.6973 0.1605 0.1032 0.6935 0.6992 0.6664 0.0673 0.3249 0.0682 0.5271 0.2686 0.9439 0.8215 0.6042 0.5124 0.8331 0.0305 0.7699 0.2162 0.1976 0.3721 0.4567 0.4126 B(:,:,5) = 0.2429 0.6098 0.9912 0.4921 0.7566 0.3377 0.8950 0.6831 0.2517 0.6218 0.4653 0.2112 0.0747 0.2256 0.6796 0.2055 0.1083 0.2004 0.5770 0.7607 0.9679 0.8373 0.7844 0.7603 0.4168 0.2585 0.9386 0.4288 0.5658 0.3285 0.7363 0.9313 0.1543 0.0375 0.7315 0.5248 0.2484 0.1306 0.2589 0.9792 0.9816 0.0690 0.2195 0.9203 0.1224 0.2264 0.9432 0.2561 0.4904 0.6570 0.6552 0.8413 0.9420 0.2263 0.5314 0.7628 0.5800 0.6295 0.6409 0.5111 0.3280 0.2872 0.8849 0.6035 0.3817 0.3811 0.0278 0.1357 0.3784 0.8895 0.2475 0.4561 0.6055 0.7020 0.0920 0.5852 0.7291 0.5001 0.6364 0.3444 0.1222 0.7225 0.1225 0.3506 0.8191 0.2135 0.1374 0.2428 0.2975 0.1321 0.3625 0.1724 0.2696 0.1704 0.1811 0.5976 0.0293 0.1974 0.6304 0.5642 B(:,:,6) = 0.0249 0.7084 0.3049 0.2871 0.3725 0.0692 0.5241 0.0825 0.5665 0.0371 0.7266 0.3143 0.2982 0.6202 0.7398 0.4635 0.0335 0.3946 0.6572 0.1156 0.9207 0.8594 0.5225 0.0181 0.4521 0.3387 0.1618 0.9742 0.0298 0.3702 0.2091 0.3602 0.0209 0.4054 0.1786 0.0626 0.9456 0.1575 0.8279 0.7186 0.3753 0.1869 0.9924 0.5361 0.4276 0.7925 0.8690 0.2512 0.0446 0.6453 0.4883 0.1996 0.4995 0.9927 0.5426 0.7893 0.5063 0.7399 0.2111 0.4871 0.7398 0.8033 0.7993 0.1591 0.7333 0.2004 0.9960 0.8168 0.8030 0.7491 0.8193 0.3229 0.6192 0.1730 0.4828 0.7668 0.0246 0.8382 0.8396 0.4267 0.6490 0.5071 0.3095 0.0003 0.1578 0.2979 0.0230 0.1844 0.2951 0.1600 0.2397 0.0640 0.3545 0.3191 0.5189 0.7912 0.3745 0.8426 0.4550 0.5106 B(:,:,7) = 0.0865 0.0036 0.2656 0.1790 0.9196 0.3339 0.8816 0.1399 0.3765 0.3780 0.6404 0.7184 0.6764 0.8068 0.6333 0.2302 0.1542 0.0488 0.1640 0.1950 0.1595 0.7066 0.0496 0.2912 0.6871 0.6802 0.1492 0.8341 0.2136 0.1250 0.8081 0.4334 0.9740 0.1574 0.8308 0.0891 0.4460 0.5891 0.3544 0.0417 0.3603 0.3793 0.4657 0.0322 0.0995 0.6176 0.0773 0.5920 0.5336 0.1964 0.6444 0.7083 0.7949 0.4336 0.3774 0.5027 0.9472 0.8290 0.5451 0.9970 0.3614 0.4948 0.9079 0.3594 0.8817 0.1338 0.5586 0.8786 0.2848 0.1402 0.1067 0.6431 0.7658 0.7416 0.8313 0.1973 0.7601 0.6013 0.8886 0.9084 0.4307 0.4079 0.2266 0.4681 0.4504 0.6900 0.8061 0.5644 0.5055 0.9627 0.1844 0.3963 0.4246 0.7362 0.4359 0.4000 0.8436 0.5288 0.4794 0.0261 B(:,:,8) = 0.3042 0.2773 0.9605 0.8465 0.3318 0.9789 0.7246 0.4815 0.0850 0.9866 0.7514 0.6954 0.2678 0.8334 0.0872 0.8063 0.4390 0.4488 0.8597 0.0768 0.4267 0.7327 0.5027 0.1681 0.0465 0.7012 0.5932 0.8414 0.6001 0.3335 0.1234 0.4781 0.8787 0.9154 0.8843 0.0803 0.9995 0.9402 0.1629 0.0946 0.2254 0.8763 0.4977 0.2620 0.3601 0.2449 0.8437 0.5691 0.3333 0.9318 0.2314 0.7702 0.4251 0.4344 0.4861 0.3747 0.8099 0.8490 0.6172 0.3154 0.6075 0.8299 0.5975 0.4339 0.7204 0.0866 0.4062 0.9462 0.1850 0.4869 0.5347 0.1543 0.6275 0.9057 0.1384 0.2310 0.7302 0.0371 0.6580 0.9462 0.8820 0.2298 0.7556 0.5311 0.6510 0.7113 0.8386 0.6365 0.1019 0.9054 0.1431 0.0817 0.1178 0.1053 0.5632 0.0240 0.4212 0.2381 0.9658 0.2932 B(:,:,9) = 0.4647 0.5283 0.9511 0.7529 0.4941 0.5533 0.6631 0.1629 0.0518 0.9116 0.3394 0.9630 0.7102 0.7149 0.0639 0.6608 0.6871 0.8578 0.1067 0.2256 0.9510 0.2019 0.3885 0.4960 0.0273 0.1475 0.4033 0.2598 0.2577 0.7251 0.1090 0.6178 0.1679 0.5767 0.2670 0.9856 0.8044 0.1939 0.5643 0.4532 0.5531 0.6278 0.8267 0.2296 0.6905 0.2679 0.2716 0.0073 0.1335 0.8402 0.9879 0.8653 0.6674 0.4587 0.8507 0.0097 0.4076 0.0346 0.7056 0.5983 0.0286 0.0439 0.9321 0.5703 0.3299 0.3764 0.5377 0.4148 0.1190 0.9318 0.3764 0.3019 0.7625 0.2392 0.8878 0.8584 0.3625 0.8930 0.7125 0.7134 0.1304 0.9661 0.5548 0.9768 0.9873 0.4390 0.8207 0.9960 0.6677 0.1599 0.2380 0.0249 0.2782 0.5198 0.2080 0.9059 0.8171 0.4887 0.9286 0.1049 B(:,:,10) = 0.0404 0.1064 0.3041 0.9524 0.2083 0.9602 0.6827 0.7508 0.1548 0.3794 0.4549 0.4545 0.0337 0.9318 0.3563 0.8695 0.1872 0.2866 0.6032 0.8064 0.1603 0.7400 0.4798 0.3166 0.5837 0.8782 0.8051 0.2752 0.5025 0.1794 0.1869 0.4635 0.5494 0.6390 0.5285 0.9236 0.5618 0.4546 0.7396 0.0742 0.9863 0.7145 0.0785 0.9378 0.5337 0.6197 0.9983 0.0751 0.5094 0.4746 0.1442 0.6877 0.2462 0.9994 0.9130 0.0398 0.0306 0.2595 0.4285 0.8915 0.8068 0.0448 0.4705 0.0916 0.3215 0.4716 0.3919 0.7185 0.3353 0.8406 0.6153 0.8998 0.0243 0.2932 0.0887 0.3393 ...

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

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

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

B = 13.3000