Cody

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

Solution 1489692

Submitted on 13 Apr 2018 by Mohammad Abir Hassan Sarker
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.7408 0.2486 0.6101 0.1820 0.1114 0.7886 0.8166 0.0330 0.6451 0.8177 0.2552 0.8853 0.9096 0.3115 0.6534 0.8869 0.2587 0.2484 0.8735 0.0275 0.5059 0.0263 0.9136 0 0.3483 0.8462 0.0023 0.9958 0.6146 0.5755 0.1282 0.1426 0.5685 0.9818 0.6972 0.3028 0.7702 0.7852 0.6901 0.2943 0.1376 0.3735 0.3116 0.1895 0.3095 0.7302 0.7585 0.6393 0.1693 0.7419 0.4683 0.6762 0.2502 0.3961 0.2439 0.8225 0.4084 0.5387 0.7318 0.2802 0.5317 0.8241 0.3793 0.8878 0.0281 0.9892 0.6411 0.4568 0.8982 0.4223 0.3961 0.3102 0.7665 0.3805 0.7462 0.3507 0.6703 0.7970 0.4729 0.6875 0.8647 0.1971 0.6469 0.7766 0.3606 0.4405 0.5732 0.9899 0.5069 0.6343 0.3937 0.4400 0.6478 0.8698 0.4305 0.3915 0.2608 0.3436 0.7792 0.2806 A(:,:,2) = 0.4492 0 0.4631 0.6330 0.3884 0.5038 0.1221 0.2170 0.7956 0.0217 0.1337 0.7221 0.8221 0.7882 0.2841 0.3532 0.0767 0.9863 0.3759 0.9695 0.5755 0.7363 0.7497 0.3372 0.9073 0.8171 0.2101 0.5055 0.8917 0.2036 0.0326 0.7210 0.4719 0.0636 0.6275 0.7316 0.1056 0.2467 0.7913 0.0080 0.2771 0.3581 0.4463 0.3034 0.6132 0.8723 0.4561 0.1030 0.9555 0.2429 0.5175 0.1811 0.7131 0.1058 0.1214 0.8943 0.7967 0.4278 0.0636 0.9233 0.2370 0.1163 0.6137 0.1113 0.4550 0.7645 0.3003 0.3130 0.1961 0.7182 0.8737 0.7574 0.6941 0.3184 0.1029 0.2357 0.4473 0.0664 0.4411 0.2031 0.0439 0.0837 0.8343 0.8176 0.1756 0.8007 0.6620 0.1279 0.7399 0.9946 0.0602 0.0383 0.9282 0.8029 0.6184 0.4970 0.7680 0.2415 0.6415 0.2668 A(:,:,3) = 0.4460 0.4868 0.4302 0.6462 0.8469 0.3574 0.6895 0.0385 0.4145 0.5169 0.7319 0.9555 0.0725 0.8825 0.5590 0.2810 0.2163 0.0571 0.3788 0.8031 0.9621 0.1750 0.3612 0.4655 0.5137 0.8173 0.5874 0.8834 0.4647 0.7437 0.6811 0.6616 0.9956 0.9710 0.8237 0.2442 0.6571 0.4447 0.2302 0.4574 0.4302 0.1179 0.2256 0.3781 0.1670 0 0.8571 0.3849 0.5259 0.9057 0.4806 0.1687 0.6592 0.1224 0.9866 0.1195 0.6628 0.2871 0.9044 0.4357 0.1674 0.3314 0.4772 0.1262 0.3284 0.7894 0.1039 0.5241 0.9841 0.1912 0.5414 0.9760 0.1640 0.3832 0.1532 0.5067 0.3265 0.1234 0.6590 0.6910 0.9256 0.6360 0.1027 0.6016 0.5229 0.7800 0.3129 0.9316 0.4615 0.0902 0.8336 0.7142 0.5263 0.5240 0.4143 0.6671 0.1485 0.5926 0.9726 0.1778 A(:,:,4) = 0.9655 0.9643 0.4960 0.8476 0.7623 0.3316 0.7083 0.3960 0.7985 0.7245 0.8473 0.5296 0.2047 0.4672 0.9822 0.2494 0.7852 0.4384 0.6956 0.4670 0.5939 0.1090 0.4977 0.1673 0.4127 0.3328 0.2703 0.9471 0.9019 0.7024 0.6856 0.9304 0.4828 0.7574 0.4720 0.9160 0.4693 0.5977 0.2698 0.3836 0.4091 0.5643 0.8180 0.4370 0.0560 0.2151 0.8785 0.8358 0.7245 0.9010 0.2575 0.7077 0.5449 0.1305 0.8878 0.8797 0.5338 0.7493 0.8612 0.8716 0.9254 0.0163 0.4109 0.6438 0.2089 0.2063 0.3633 0.2934 0.0937 0.1427 0.4302 0.0538 0.3954 0.3722 0.8746 0.9161 0.1283 0.2892 0.7932 0.5932 0.9556 0.1184 0.9044 0.9948 0.6417 0.2503 0.7201 0.3416 0.3447 0.2991 0.6627 0.4518 0.4335 0.4578 0.1274 0.8413 0.5600 0.0904 0.8172 0.8416 A(:,:,5) = 0.8327 0.4819 0.0546 0.7522 0.1183 0.3665 0.4757 0.0382 0.4870 0.2778 0.2880 0.6144 0.3793 0.7768 0.6723 0.0573 0.6807 0.8471 0.8751 0.7829 0.1741 0.4264 0.4719 0.6031 0.8971 0.3156 0.7748 0.3876 0.2211 0.6910 0.9100 0.4613 0.9724 0.2368 0.1628 0.6352 0.6803 0.8582 0.1343 0.2269 0.2198 0.1145 0.9633 0.3130 0.1233 0.9345 0.5399 0.4781 0.0339 0.4285 0.3308 0.8045 0.7961 0.1703 0.7264 0.0322 0.0125 0.4591 0.3239 0.8816 0.2481 0.8678 0.4902 0.7031 0.2941 0.0784 0.9920 0.7000 0.7729 0.6301 0.5918 0.0507 0.9739 0.5682 0.9426 0.9420 0.7295 0.5584 0.9459 0.0055 0.8569 0.2550 0.9210 0.9238 0.0778 0.2210 0.1058 0.6118 0.3156 0.3124 0.7171 0.2293 0.3149 0.1686 0.1536 0.1776 0.2141 0.4530 0.4701 0.3843 A(:,:,6) = 0.4040 0.8244 0.1140 0.0054 0.7991 0.9673 0.4942 0.3931 0.3942 0.4403 0.9049 0.4138 0.5129 0.5538 0.0143 0.4992 0.9741 0.6217 0.3094 0.3538 0.8072 0.9363 0.7751 0.3181 0.9052 0.5418 0.8904 0.2600 0.1128 0.8860 0.5249 0.3101 0.1110 0.8362 0.7914 0.4693 0.0302 0.1200 0.3115 0.1386 0.7418 0.9875 0.8651 0.3069 0.5642 0.2968 0.5241 0.7061 0.2045 0.9485 0.7138 0.6835 0.0447 0.1843 0.7151 0.7103 0.0149 0.9561 0.9980 0.4730 0.9041 0.5442 0.3421 0.9674 0.0397 0.2356 0.0344 0.0593 0.9490 0.1651 0.7965 0.8433 0.3837 0.0224 0.0335 0.8752 0.6960 0.9758 0.3703 0.5465 0.6972 0.7619 0.4197 0.7765 0.0931 0.6878 0.9401 0.5861 0.4829 0.2836 0.5214 0.7790 0.6395 0.0766 0.1542 0.8606 0.8307 0.3623 0.1846 0.4964 A(:,:,7) = 0.1535 0.2705 0.6038 0.5727 0.3532 0.4453 0.5411 0.5679 0.3015 0.4349 0.5735 0.8607 0.9927 0.8281 0.6451 0.2643 0.8067 0.2009 0.5043 0.1756 0.0034 0.7170 0.7928 0.5751 0.9589 0.4138 0.2236 0.1138 0.9307 0.1100 0.0160 0.6793 0.1952 0.8859 0.0272 0.6197 0.3010 0.1665 0.9024 0.0457 0.3085 0.1692 0.0737 0.2487 0.8406 0.1053 0.8069 0.3483 0.0448 0.3790 0.9746 0.1855 0.5374 0.8141 0.0781 0.8667 0.6514 0.8897 0.5569 0.9236 0.4679 0.3401 0.4429 0.6805 0.2804 0.2429 0.6135 0.6007 0.3110 0.4778 0.8839 0.5796 0.7473 0.1737 0.8528 0.7822 0.0052 0.7779 0.1035 0.8750 0.6398 0.7443 0.4939 0.9044 0.7448 0.9937 0.5367 0.8574 0.4926 0.1645 0.3266 0.6028 0.1526 0.5357 0.6191 0.0966 0.2328 0.3619 0.4575 0.6384 A(:,:,8) = 0.7449 0.8367 0.9782 0.7437 0.3416 0.0984 0.9220 0.3428 0.4670 0.7860 0.6160 0.3230 0.0759 0.8000 0.3028 0.6930 0.1170 0.8323 0.9209 0.8464 0.5119 0.4990 0.6652 0.3693 0.4523 0.8408 0.3338 0.2400 0.1605 0.8984 0.2516 0.9573 0.0459 0.4539 0.2257 0.4872 0.5028 0.1375 0.5970 0.3559 0.4877 0.8923 0.5922 0.5371 0.9373 0.8159 0.6269 0.2155 0.8892 0.0067 0.0925 0.6581 0.6645 0.8961 0.5508 0.2878 0.9690 0.8227 0.7250 0.0914 0.4725 0.0467 0.7902 0.3665 0.1474 0.0534 0.9217 0.4463 0.7068 0.6439 0.3282 0.7583 0.5030 0.9106 0.2319 0.1048 0.8947 0.0400 0.7850 0.9463 0.4328 0.4786 0.3351 0.2348 0.7359 0.2513 0.2126 0.2830 0.4877 0.5246 0.3270 0.1331 0.4344 0.7925 0.4165 0.5806 0.9519 0.5496 0.9160 0.7663 A(:,:,9) = 0.2210 0.1583 0.8829 0.4298 0.9739 0.9685 0.2423 0.9571 0.6632 0.8382 0.1085 0.4571 0.5639 0.0169 0.1319 0.0752 0.9539 0.2858 0.8602 0.5565 0.5479 0.6125 0.5941 0.2391 0.6862 0.7474 0.2180 0.2521 0.5789 0.9353 0.7322 0.4557 0.5299 0.1991 0.0681 0.0663 0.8050 0.2938 0.2233 0.6824 0.8962 0.9349 0.3327 0.6232 0.2255 0.9000 0.5059 0.5933 0.4381 0.7631 0.3291 0.1948 0.9056 0.4196 0.5009 0.8651 0.9503 0.1932 0.8156 0.2101 0.0051 0.4447 0.6027 0.4498 0.5022 0.3029 0.3213 0.6508 0.8193 0.4458 0.1774 0.1013 0.4323 0.5607 0.9151 0.8574 0.9715 0.6221 0.2807 0.9849 0.7751 0.8299 0.0233 0.3266 0.8156 0.7461 0.4318 0.8986 0.7192 0.1082 0.2436 0.7494 0.4278 0.4761 0.5436 0.0724 0.7544 0.4364 0.2657 0.6260 A(:,:,10) = 0.8527 0.3772 0.6807 0.5212 0.2438 0.7288 0.4102 0.6861 0.3342 0.2574 0.2865 0.5544 0.1043 0.1618 0.3476 0.5316 0.3345 0.3096 0.0888 0.0503 0.3820 0.4500 0.9266 0.1981 0.9883 0.0761 0.2515 0.2928 0.9906 0.4888 0.7352 0.5099 0.2321 0.4713 0.5693 0.3967 0.6629 0.5735 0.0035 0.9597 0.3448 0.4771 0.3882 0.1359 0.6784 0.4162 0.0323 0.6807 0.1335 0.2950 0.1781 0.5455 0.8104 0.8746 0.9369 0.9792 0.4356 0.4082 0.3076 0.9259 0.6049 0.0736 0.2486 0.6766 0.9808 0.2289 0.7928 0.3440 0.3552 0.0918 0.5072 0.8397 0.2807 0.2078 0.0474 0.4885 ...

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

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!