Cody

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

Solution 2094978

Submitted on 16 Jan 2020
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   Fail
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

Assertion failed.

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

Assertion failed.

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

Assertion failed.

5   Fail
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.7311 0.2961 0.9442 0.8630 0.9810 0.4815 0.1184 0.3503 0.8883 0.7284 0.2481 0.7159 0.4786 0.7432 0.1805 0.5184 0.0215 0.2328 0.0135 0.1521 0.9963 0.1778 0.0797 0 0.6444 0.2716 0.6217 0.1126 0.4705 0.4618 0.2353 0.9156 0.1796 0.7486 0.6752 0.9521 0.6148 0.1289 0.3993 0.4819 0.4113 0.3064 0.6541 0.3390 0.1413 0.1912 0.9777 0.7147 0.9042 0.4143 0.6175 0.2803 0.8388 0.8726 0.1770 0.7055 0.5141 0.2765 0.1309 0.8024 0.4453 0.4848 0.7488 0.3972 0.7341 0.2099 0.4462 0.0849 0.4241 0.0644 0.3849 0.2056 0.9057 0.0913 0.4281 0.6576 0.6850 0.2686 0.6628 0.1382 0.9391 0.9310 0.2475 0.3155 0.5176 0.3315 0.0755 0.7469 0.8671 0.2463 0.7689 0.5200 0.1218 0.8776 0.0830 0.9036 0.7255 0.1080 0.5284 0.0492 A(:,:,2) = 0.7761 0 0.1111 0.1368 0.1635 0.1794 0.3212 0.3587 0.5799 0.1895 0.8547 0.1549 0.2076 0.9912 0.4457 0.1957 0.3843 0.1954 0.4454 0.5656 0.3476 0.6367 0.5183 0.1912 0.4232 0.2500 0.6608 0.2322 0.6539 0.3476 0.3121 0.9301 0.7536 0.6422 0.0884 0.9244 0.4245 0.6789 0.3574 0.8393 0.4114 0.2265 0.5652 0.4967 0.7753 0.6949 0.2561 0.1282 0.8967 0.9236 0.1737 0.3655 0.8067 0.8112 0.0770 0.8771 0.5011 0.6726 0.2960 0.9362 0.8412 0.3465 0.9470 0.6045 0.9804 0.7638 0.1882 0.7968 0.0234 0.2368 0.8964 0.0415 0.0463 0.9753 0.5792 0.8772 0.7046 0.7531 0.1170 0.0273 0.0575 0.5155 0.2386 0.5734 0.2048 0.8680 0.5841 0.4731 0.9492 0.7482 0.7983 0.1662 0.7782 0.0390 0.2583 0.8369 0.2144 0.5489 0.0554 0.0325 A(:,:,3) = 0.1447 0.5383 0.3810 0.7319 0.3505 0.0855 0.4072 0.7199 0.2060 0.9527 0.8224 0.8450 0.6738 0.4233 0.3903 0.0628 0.4392 0.7306 0.6084 0.9423 0.8831 0.7593 0.9692 0.5387 0.3288 0.2017 0.2763 0.6552 0.1371 0.1243 0.5883 0.3497 0.2456 0.3011 0.4487 0.7774 0.1307 0.7448 0.2644 0.0459 0.7092 0.4762 0.7233 0.6915 0.2155 0 0.5313 0.5531 0.0611 0.7137 0.9540 0.3760 0.7970 0.8718 0.2569 0.6308 0.1652 0.9252 0.8529 0.0876 0.8665 0.7477 0.5059 0.6192 0.1365 0.8990 0.5420 0.8414 0.9953 0.8131 0.8489 0.4195 0.3827 0.9682 0.2281 0.7151 0.9669 0.3036 0.1900 0.5905 0.9693 0.9179 0.9113 0.3173 0.9362 0.4355 0.1091 0.9943 0.5744 0.2291 0.7055 0.7958 0.1586 0.8638 0.2852 0.6584 0.8804 0.6552 0.1462 0.4029 A(:,:,4) = 0.0161 0.2701 0.7452 0.4420 0.4492 0.6680 0.1977 0.6576 0.4209 0.7848 0.0565 0.3995 0.7977 0.2255 0.0960 0.8491 0.7720 0.5638 0.8195 0.9295 0.7555 0.8445 0.5517 0.4475 0.0216 0.8651 0.3533 0.1603 0.3997 0.8442 0.3796 0.4808 0.5077 0.7762 0.0491 0.7150 0.1335 0.0835 0.8965 0.8697 0.7134 0.9703 0.8524 0.5732 0.9446 0.2530 0.9131 0.1082 0.6447 0.3414 0.7761 0.4248 0.6916 0.4556 0.3467 0.2375 0.3072 0.6674 0.0119 0.2432 0.3547 0.8278 0.7230 0.5767 0.5504 0.3453 0.6018 0.5510 0.2246 0.5761 0.0282 0.6678 0.6340 0.2848 0.4493 0.3561 0.4556 0.1667 0.5769 0.1868 0.1956 0.5848 0.8818 0.5451 0.2339 0.6445 0.9241 0.3034 0.5880 0.1322 0.4773 0.0873 0.5842 0.6920 0.4334 0.0078 0.2832 0.9250 0.4634 0.6248 A(:,:,5) = 0.6439 0.3608 0.4641 0.4063 0.1820 0.4416 0.4443 0.7684 0.2726 0.4724 0.8146 0.8566 0.1720 0.1203 0.2932 0.7450 0.0534 0.1014 0.3097 0.8824 0.2952 0.6891 0.4922 0.5356 0.6276 0.5579 0.6769 0.0501 0.9644 0.9212 0.3796 0.4929 0.2395 0.7325 0.5529 0.5829 0.8632 0.2964 0.1520 0.5580 0.9065 0.6320 0.0418 0.4368 0.5240 0.2363 0.5353 0.7518 0.0808 0.7995 0.4394 0.0671 0.5359 0.0121 0.8410 0.2966 0.5465 0.7812 0.1902 0.8879 0.1206 0.3551 0.5135 0.1453 0.8240 0.6503 0.7270 0.6807 0.9627 0.9276 0.0979 0.8390 0.4588 0.2386 0.8367 0.6647 0.9776 0.7584 0.3071 0.5864 0.7906 0.1052 0.3896 0.9440 0.6758 0.1480 0.5945 0.0983 0.1027 0.2963 0.7375 0.8498 0.9221 0.5213 0.0520 0.7661 0.9930 0.0978 0.2990 0.1321 A(:,:,6) = 0.2490 0.9345 0.7908 0.4653 0.2027 0.3783 0.6266 0.3639 0.7781 0.2466 0.4062 0.6321 0.2014 0.4919 0.1226 0.6641 0.1442 0.3996 0.5283 0.5514 0.4726 0.6057 0.6269 0.7430 0.7062 0.2355 0.1669 0.5018 0.7281 0.7643 0.2298 0.9347 0.7566 0.1687 0.0806 0.3791 0.1975 0.5421 0.5365 0.1685 0.5507 0.3613 0.2196 0.5035 0.0582 0.3061 0.9643 0.0822 0.3355 0.9395 0.8272 0.3656 0.4403 0.7545 0.3868 0.7897 0.0385 0.7811 0.3342 0.3036 0.7033 0.3549 0.4597 0.2544 0.8220 0.0450 0.6066 0.2121 0.7598 0.7407 0.2641 0.9894 0.1967 0.6158 0.8622 0.9847 0.2877 0.5505 0.5762 0.0602 0.6903 0.8646 0.8909 0.1757 0.5879 0.3692 0.7466 0.0720 0.7263 0.5687 0.9787 0.4493 0.6344 0.5592 0.1745 0.6209 0.2635 0.3731 0.9760 0.7924 A(:,:,7) = 0.5318 0.0810 0.9816 0.9618 0.3752 0.8423 0.7573 0.4552 0.3795 0.0363 0.4956 0.8874 0.8573 0.5274 0.6187 0.7823 0.3641 0.5899 0.9857 0.5510 0.2802 0.1252 0.3150 0.9752 0.8238 0.0687 0.8194 0.5842 0.5657 0.1442 0.9825 0.9902 0.0012 0.5500 0.9620 0.5444 0.0859 0.9789 0.1750 0.6819 0.9879 0.9143 0.6478 0.7006 0.7734 0.3079 0.4452 0.0210 0.9195 0.4900 0.4241 0.8957 0.2672 0.8748 0.2976 0.6641 0.1598 0.8251 0.4963 0.6487 0.9557 0.8402 0.9642 0.0108 0.2048 0.9671 0.2206 0.5982 0.0287 0.4753 0.9463 0.2420 0.2869 0.3229 0.6488 0.2566 0.4150 0.7719 0.1379 0.4847 0.5481 0.8058 0.9485 0.0093 0.6060 0.8398 0.3373 0.2893 0.4048 0.7489 0.3565 0.3716 0.4593 0.6027 0.5158 0.9801 0.9687 0.1636 0.0507 0.8390 A(:,:,8) = 0.6903 0.2277 0.1370 0.5068 0.5902 0.1169 0.6356 0.6281 0.4614 0.3945 0.7556 0.9917 0.2318 0.8156 0.3106 0.9816 0.0285 0.2036 0.0148 0.4142 0.5322 0.7574 0.1192 0.3690 0.1498 0.3659 0.8076 0.6631 0.5959 0.5829 0.9511 0.3355 0.2522 0.3390 0.3341 0.2261 0.4850 0.0677 0.0180 0.3822 0.9663 0.3954 0.2907 0.2280 0.3204 0.6280 0.6280 0.8412 0.1027 0.9165 0.9115 0.9358 0.6131 0.4507 0.8835 0.5827 0.3939 0.6501 0.6854 0.4292 0.9071 0.8839 0.3519 0.7588 0.3882 0.5223 0.0344 0.5118 0.3181 0.2376 0.6504 0.5898 0.3271 0.3353 0.2387 0.4508 0.0001 0.2437 0.7096 0.1747 0.0904 0.4406 0.1364 0.5320 0.4760 0.2946 0.4792 0.0225 0.0374 0.3218 0.6479 0.7092 0.6049 0.0244 0.3986 0.3041 0.5992 0.0577 0.6584 0.2989 A(:,:,9) = 0.9332 0.8404 0.1817 0.7733 0.1832 0.8909 0.8765 0.5460 0.6233 0.1690 0.3097 0.5751 0.6570 0.5216 0.9138 0.4930 0.0431 0.5753 0.0829 0.8511 0.1536 0.8504 0.9473 0.7201 0.8238 0.9389 0.0999 0.1045 0.6141 0.9207 0.3748 0.8420 0.9117 0.0021 0.9460 0.3262 0.3908 0.6849 0.7693 0.8448 0.4429 0.0079 0.8427 0.7248 0.1556 0.4893 0.3320 0.3503 0.9470 0.3457 0.9815 0.1287 0.8084 0.2101 0.1147 0.7696 0.0135 0.7677 0.7990 0.5394 0.8325 0.1033 0.2488 0.9408 0.7982 0.5573 0.8611 0.8985 0.6452 0.0725 0.0751 0.5365 0.1310 0.3710 0.9311 0.3636 0.4564 0.5278 0.6922 0.7135 0.9367 0.9071 0.8963 0.0490 0.0187 0.7322 0.3997 0.3912 0.1769 0.1956 0.7310 0.2468 0.0848 0.5376 0.1654 0.6888 0.7705 0.6535 0.6719 0.2052 A(:,:,10) = 0.0704 0.9543 0.9833 0.6946 0.2683 0.8255 0.4533 0.2820 0.0042 0.4085 0.2276 0.5298 0.1921 0.7330 0.7877 0.1702 0.7469 0.0972 0.2336 0.4899 0.4635 0.8086 0.6811 0.3657 0.4829 0.9881 0.3354 0.9142 0.3095 0.6968 0.6374 0.6863 0.7301 0.3844 0.6837 0.4239 0.6522 0.5972 0.6921 0.9160 0.3906 0.5298 0.8356 0.1529 0.5243 0.1555 0.0499 0.8884 0.1330 0.4109 0.8406 0.0166 0.6206 0.7530 0.8476 0.7523 0.5942 0.7430 0.8121 0.2185 0.1720 0.5515 0.0982 0.6271 0.5630 0.9376 0.5813 0.7859 0.5033 0.3020 0.8055 0.1576 0.1785 0.8990 0.5214 0.8074 ...

Assertion failed.

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

Assertion failed.

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

Assertion failed.

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!