Cody

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

Solution 1600688

Submitted on 4 Aug 2018 by Kodavati Mahendra
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.6533 0.3896 0.3787 0.1591 0.6377 0.9614 0.3194 0.4265 0.7517 0.4770 0.1601 0.8189 0.1566 0.7097 0.8904 0.0186 0.3270 0.5211 0.8102 0.9202 0.0443 0.4263 0.3066 0 0.7823 0.9077 0.7120 0.5968 0.4581 0.2280 0.7727 0.0767 0.4672 0.9361 0.1048 0.7055 0.8701 0.3918 0.6005 0.1496 0.5053 0.4757 0.7145 0.2710 0.3865 0.2967 0.1408 0.7471 0.1926 0.3398 0.8065 0.9911 0.7916 0.7395 0.5154 0.2036 0.7371 0.8274 0.1790 0.6306 0.7455 0.3627 0.3296 0.7494 0.2370 0.1173 0.2883 0.9248 0.4922 0.9609 0.5401 0.6153 0.8940 0.6881 0.8653 0.2976 0.9119 0.3392 0.2469 0.6412 0.8853 0.9793 0.3804 0.2185 0.3147 0.0790 0.4169 0.7413 0.6695 0.6801 0.6649 0.7005 0.3487 0.2658 0.4186 0.8997 0.1926 0.3612 0.9581 0.0145 A(:,:,2) = 0.5748 0 0.1017 0.1206 0.8210 0.9501 0.7930 0.1377 0.5398 0.2218 0.4546 0.1725 0.6921 0.2699 0.5702 0.8179 0.6743 0.8914 0.5025 0.7144 0.8017 0.4733 0.3657 0.1321 0.0823 0.2607 0.5007 0.0910 0.5127 0.9809 0.4101 0.6408 0.0651 0.6404 0.5525 0.8050 0.3470 0.0520 0.0179 0.3036 0.7414 0.5989 0.9724 0.6656 0.9150 0.5562 0.7456 0.6496 0.9424 0.3135 0.5955 0.3748 0.3104 0.7527 0.0233 0.4222 0.2726 0.6111 0.7882 0.4597 0.1168 0.2958 0.2739 0.6726 0.3221 0.6294 0.1118 0.4701 0.5150 0.0049 0.4258 0.9303 0.5882 0.3940 0.9564 0.4811 0.3352 0.2905 0.7364 0.8291 0.8416 0.9555 0.1316 0.0698 0.9559 0.9489 0.8217 0.6501 0.9229 0.8503 0.1233 0.9764 0.9154 0.9030 0.7489 0.1479 0.8773 0.1691 0.2394 0.7876 A(:,:,3) = 0.1032 0.6930 0.3722 0.9186 0.2597 0.1627 0.1381 0.9858 0.9850 0.4849 0.5467 0.7788 0.0087 0.0241 0.2316 0.1387 0.3561 0.7933 0.0841 0.3384 0.0779 0.1276 0.0444 0.8410 0.7489 0.4840 0.1975 0.0108 0.1330 0.8863 0.9380 0.0330 0.4827 0.5111 0.7617 0.1386 0.0227 0.6101 0.2860 0.0471 0.7834 0.4175 0.3363 0.8577 0.0528 0 0.0895 0.0462 0.7670 0.8986 0.2988 0.5410 0.0518 0.7082 0.6398 0.6971 0.2469 0.4724 0.7313 0.3244 0.1534 0.3720 0.6189 0.6279 0.5877 0.1222 0.9913 0.1580 0.5698 0.8987 0.2138 0.4270 0.0884 0.5898 0.5826 0.1481 0.8025 0.8046 0.2167 0.0867 0.5674 0.3209 0.4324 0.8697 0.5431 0.8789 0.4686 0.4736 0.4830 0.3090 0.4627 0.9061 0.8857 0.7688 0.9285 0.1568 0.8174 0.7072 0.9452 0.5856 A(:,:,4) = 0.5737 0.4539 0.1961 0.7419 0.1326 0.9273 0.2359 0.8737 0.0528 0.4779 0.8258 0.8565 0.5386 0.9216 0.7059 0.5144 0.0728 0.6929 0.8787 0.7778 0.0594 0.8567 0.7628 0.1914 0.3442 0.4788 0.7959 0.1063 0.9712 0.6534 0.3243 0.8860 0.8057 0.4681 0.3012 0.4708 0.4720 0.0077 0.3965 0.6820 0.6511 0.6450 0.0648 0.6650 0.0961 0.3092 0.4889 0.3374 0.8636 0.8284 0.4354 0.1369 0.6515 0.6716 0.0369 0.7314 0.5257 0.9772 0.4951 0.6458 0.7200 0.9740 0.3569 0.0133 0.9194 0.0744 0.8024 0.1100 0.7899 0.8337 0.6186 0.4822 0.9925 0.0204 0.6993 0.5971 0.1679 0.3435 0.3723 0.2442 0.5200 0.1720 0.9733 0.3276 0.4781 0.7044 0.0909 0.6163 0.9688 0.7736 0.4597 0.3266 0.3818 0.9484 0.4178 0.7914 0.5142 0.0475 0.4374 0.3277 A(:,:,5) = 0.4985 0.7249 0.2502 0.2172 0.8857 0.1033 0.9974 0.2167 0.6237 0.5772 0.1071 0.0736 0.7740 0.7070 0.3637 0.1733 0.4660 0.9166 0.8030 0.2875 0.4346 0.8194 0.2801 0.5745 0.0045 0.5346 0.8809 0.9189 0.0373 0.5664 0.4952 0.9113 0.6020 0.5411 0.2065 0.7357 0.1271 0.3238 0.9147 0.3170 0.6692 0.6427 0.0529 0.7594 0.3262 0.3844 0.4341 0.0523 0.6584 0.6075 0.5133 0.2774 0.2669 0.1791 0.5872 0.5081 0.9755 0.4179 0.1865 0.5747 0.2047 0.4782 0.5993 0.9767 0.8841 0.9949 0.4133 0.6399 0.0954 0.1267 0.5575 0.7010 0.3349 0.9536 0.2727 0.6828 0.7141 0.2301 0.9437 0.0102 0.4207 0.2179 0.2098 0.6376 0.5326 0.3321 0.6562 0.8093 0.6146 0.9925 0.7376 0.8034 0.3635 0.4595 0.6154 0.3743 0.0536 0.2601 0.5231 0.2231 A(:,:,6) = 0.3713 0.5318 0.5221 0.3987 0.7690 0.7497 0.3391 0.7805 0.2496 0.0533 0.3336 0.0763 0.2234 0.6289 0.0648 0.1024 0.5398 0.2971 0.5534 0.7514 0.2472 0.5182 0.7319 0.2266 0.8883 0.8610 0.2563 0.5033 0.8980 0.1527 0.4518 0.7515 0.7619 0.6873 0.7870 0.0166 0.6244 0.6373 0.9124 0.1276 0.6572 0.6420 0.1774 0.0390 0.6794 0.6762 0.8691 0.6326 0.5448 0.2604 0.5447 0.4363 0.3832 0.0295 0.6595 0.0804 0.0442 0.8276 0.3477 0.5201 0.2992 0.5664 0.0716 0.2735 0.7268 0.5274 0.0262 0.3019 0.6412 0.0445 0.7788 0.7657 0.1442 0.6192 0.9584 0.2619 0.5581 0.2599 0.8812 0.0054 0.8106 0.8801 0.5045 0.6087 0.4229 0.1671 0.0041 0.4693 0.4881 0.8802 0.5766 0.8850 0.1671 0.4809 0.5948 0.6586 0.4395 0.7637 0.6375 0.7835 A(:,:,7) = 0.3048 0.8396 0.1631 0.1317 0.8817 0.4521 0.1549 0.5047 0.9241 0.0543 0.3418 0.1260 0.7145 0.9052 0.6145 0.0250 0.3493 0.9080 0.8035 0.4427 0.1412 0.5215 0.3330 0.1833 0.4637 0.2045 0.1910 0.7381 0.7953 0.2829 0.9373 0.4221 0.6464 0.7368 0.1677 0.4158 0.6931 0.0837 0.5222 0.8904 0.1004 0.1635 0.0976 0.1820 0.7235 0.3520 0.3023 0.1736 0.8111 0.5942 0.4754 0.8282 0.3632 0.2514 0.9419 0.6854 0.9167 0.9013 0.9331 0.8103 0.2070 0.1327 0.0708 0.7808 0.7609 0.6436 0.7927 0.8990 0.7337 0.8191 0.6797 0.6963 0.6839 0.3842 0.1189 0.7139 0.8534 0.3651 0.3240 0.6460 0.9292 0.3554 0.7984 0.9717 0.8223 0.9085 0.0783 0.0013 0.5465 0.9413 0.7666 0.9291 0.0158 0.8041 0.3112 0.3996 0.1070 0.6885 0.1393 0.6803 A(:,:,8) = 0.4187 0.5365 0.0096 0.3896 0.8802 0.8480 0.8507 0.9981 0.5556 0.2658 0.6790 0.7265 0.9917 0.2617 0.2086 0.1054 0.6251 0.5772 0.9064 0.2849 0.9380 0.0323 0.8768 0.5318 0.7211 0.3564 0.2601 0.6598 0.5030 0.2810 0.7290 0.6087 0.1976 0.1495 0.4450 0.2858 0.2996 0.0035 0.4237 0.3780 0.0750 0.7062 0.8056 0.7342 0.7112 0.6868 0.7369 0.6888 0.4713 0.1102 0.5355 0.3895 0.8174 0.4386 0.4586 0.0134 0.5044 0.3148 0.6341 0.1979 0.1923 0.3521 0.2812 0.2993 0.1856 0.0703 0.9085 0.1647 0.7385 0.8926 0.1472 0.2845 0.1842 0.3672 0.1587 0.0821 0.7663 0.4151 0.9284 0.4650 0.5954 0.8732 0.1984 0.2319 0.2159 0.0162 0.5033 0.2457 0.5669 0.2748 0.7265 0.6225 0.3758 0.7254 0.7354 0.9805 0.7851 0.2632 0.1002 0.0818 A(:,:,9) = 0.8982 0.3958 0.9959 0.5717 0.4649 0.5711 0.4404 0.0355 0.1162 0.3205 0.9214 0.9957 0.5010 0.9321 0.6225 0.3383 0.6260 0.2151 0.1828 0.8830 0.9995 0.8027 0.0463 0.3777 0.9966 0.9987 0.3958 0.7573 0.4623 0.3265 0.6604 0.7888 0.5678 0.2440 0.3402 0.1621 0.1062 0.0998 0.3112 0.5692 0.1181 0.3933 0.4591 0.2393 0.1477 0.4470 0.1653 0.2938 0.1903 0.3582 0.4525 0.3096 0.9326 0.6905 0.3809 0.9919 0.5903 0.1071 0.1337 0.4749 0.8977 0.5018 0.5343 0.1567 0.3066 0.6160 0.4368 0.0085 0.1011 0.9387 0.0772 0.9729 0.6355 0.9580 0.8059 0.1780 0.7642 0.3967 0.1421 0.0362 0.0959 0.5167 0.4033 0.6658 0.3166 0.5952 0.5580 0.7014 0.4169 0.9997 0.9558 0.5814 0.8482 0.5241 0.5062 0.0627 0.3177 0.0683 0.0716 0.4511 A(:,:,10) = 0.2722 0.7762 0.0157 0.5112 0.9123 0.5816 0.2362 0.8310 0.1138 0.8821 0.2763 0.5035 0.7298 0.4210 0.3284 0.6396 0.2986 0.4576 0.4209 0.3993 0.7112 0.3990 0.4946 0.8629 0.6070 0.6552 0.2006 0.1159 0.5819 0.7598 0.1090 0.7529 0.2877 0.8874 0.3932 0.4571 0.0857 0.7289 0.4219 0.7144 0.8987 0.5504 0.1877 0.2368 0.0723 0.5496 0.5124 0.5053 0.4460 0.4651 0.6219 0.3903 0.8198 0.3994 0.8202 0.3427 0.7855 0.7605 0.6954 0.0854 0.7749 0.9158 0.9525 0.0735 0.9106 0.5904 0.8312 0.6940 0.1411 0.0925 0.1004 0.3528 0.1861 0.6041 0.8585 0.7830 ...

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

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

### Community Treasure Hunt

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

Start Hunting!