Cody

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

Solution 1496515

Submitted on 18 Apr 2018 by Sami Qorchi
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.1636 0.0956 0.9442 0.8847 0.0416 0.8044 0.0431 0.4163 0.4743 0.1457 0.7207 0.1066 0.6717 0.5993 0.6052 0.8065 0.0502 0.7863 0.0989 0.4535 0.6735 0.6188 0.9822 0 0.2090 0.2546 0.4473 0.9510 0.0205 0.1889 0.9027 0.8041 0.2776 0.0709 0.2254 0.0993 0.5897 0.2272 0.4772 0.0579 0.4956 0.6617 0.2946 0.1129 0.3636 0.6811 0.0536 0.6607 0.4580 0.4776 0.9196 0.0616 0.6088 0.6448 0.9570 0.7774 0.4010 0.0966 0.3376 0.5785 0.8102 0.7687 0.3285 0.0543 0.2027 0.5193 0.0353 0.5398 0.6616 0.8526 0.5602 0.6532 0.3689 0.9456 0.9614 0.2691 0.2284 0.5493 0.0159 0.2205 0.1941 0.0759 0.1400 0.0463 0.8151 0.3171 0.0191 0.4221 0.1425 0.8908 0.6339 0.7635 0.0338 0.8030 0.3083 0.3432 0.2289 0.7105 0.0392 0.4598 B(:,:,2) = 0.2099 0 0.0333 0.8106 0.5477 0.9025 0.0746 0.0509 0.8660 0.2622 0.3367 0.2530 0.9449 0.2999 0.5782 0.3372 0.3061 0.4211 0.1083 0.3286 0.1770 0.1421 0.7523 0.9483 0.5551 0.0525 0.2890 0.5209 0.1998 0.3327 0.3212 0.3122 0.5233 0.3306 0.3295 0.6577 0.9805 0.2279 0.9409 0.9516 0.4254 0.9733 0.0354 0.1756 0.2164 0.2676 0.8075 0.9649 0.6256 0.0470 0.0950 0.3402 0.3313 0.9668 0.2445 0.0715 0.4760 0.5616 0.0065 0.2655 0.2308 0.0054 0.4456 0.1347 0.2324 0.2027 0.3745 0.6579 0.8694 0.5747 0.0169 0.7750 0.4971 0.2919 0.8641 0.3063 0.8080 0.3878 0.6109 0.4900 0.3406 0.2500 0.8087 0.1318 0.9283 0.4276 0.5916 0.3988 0.8037 0.3082 0.3704 0.5977 0.4884 0.6189 0.5197 0.1355 0.8067 0.4157 0.2554 0.7086 B(:,:,3) = 0.8033 0.7896 0.9002 0.8654 0.0136 0.3910 0.7851 0.7209 0.6944 0.4788 0.0414 0.3864 0.1850 0.0354 0.1491 0.8863 0.3110 0.7629 0.1328 0.0814 0.5052 0.0999 0.0797 0.3121 0.9782 0.5722 0.8002 0.0053 0.7258 0.6693 0.4523 0.9950 0.3549 0.8980 0.2076 0.3964 0.9973 0.2268 0.5981 0.9221 0.2330 0.6872 0.4255 0.1952 0.5497 0 0.8724 0.7157 0.0950 0.2650 0.4990 0.0263 0.7973 0.0391 0.2647 0.3004 0.2222 0.7609 0.3208 0.5619 0.6746 0.5457 0.1626 0.5504 0.0297 0.3426 0.8448 0.3966 0.2385 0.3069 0.8930 0.6492 0.2350 0.0088 0.7618 0.4296 0.3534 0.2006 0.0399 0.7688 0.9234 0.6734 0.3544 0.2298 0.1067 0.5854 0.2690 0.2257 0.3265 0.3704 0.6311 0.5015 0.8393 0.2474 0.7085 0.1388 0.2452 0.3681 0.6308 0.0081 B(:,:,4) = 0.2682 0.0600 0.3663 0.3984 0.4177 0.6617 0.8815 0.2039 0.3126 0.3175 0.5903 0.8325 0.8607 0.5072 0.3040 0.4443 0.2755 0.0948 0.1929 0.2755 0.7435 0.6358 0.4971 0.6627 0.3539 0.6318 0.4068 0.0901 0.7869 0.0596 0.6842 0.2435 0.5027 0.5659 0.0936 0.4278 0.5961 0.5019 0.2079 0.3012 0.4796 0.3737 0.3692 0.8923 0.3669 0.5026 0.5038 0.5244 0.1133 0.0005 0.6482 0.2086 0.0893 0.3366 0.5556 0.7187 0.2959 0.1708 0.9363 0.8938 0.4640 0.6019 0.4423 0.5142 0.6410 0.5240 0.0985 0.0177 0.9332 0.1375 0.3894 0.9545 0.0651 0.0700 0.0907 0.3639 0.8472 0.6544 0.0630 0.5607 0.3422 0.5352 0.5456 0.5377 0.2810 0.0552 0.6019 0.0051 0.7585 0.1623 0.5409 0.5777 0.1145 0.7643 0.6600 0.8373 0.1408 0.6887 0.7110 0.4707 B(:,:,5) = 0.4292 0.1963 0.8555 0.7426 0.2172 0.6972 0.5163 0.3722 0.0791 0.2591 0.1834 0.9291 0.9172 0.4007 0.8384 0.4387 0.3917 0.4605 0.0642 0.3776 0.6509 0.9863 0.2700 0.1175 0.7195 0.4088 0.7577 0.4660 0.5289 0.2879 0.1638 0.3034 0.2280 0.7352 0.1705 0.0673 0.8964 0.4773 0.5879 0.0447 0.3099 0.1156 0.1158 0.2695 0.3976 0.9581 0.8074 0.9204 0.5472 0.7448 0.2612 0.9346 0.6126 0.1379 0.3349 0.9334 0.0321 0.7765 0.3602 0.9293 0.4972 0.8756 0.7985 0.3928 0.0183 0.4156 0.9030 0.4887 0.6480 0.9217 0.2176 0.3701 0.6062 0.5516 0.6768 0.8232 0.8673 0.8577 0.0043 0.9332 0.3901 0.9660 0.7135 0.1664 0.2403 0.5755 0.2730 0.6200 0.6797 0.5806 0.3486 0.9894 0.6271 0.4159 0.5396 0.6120 0.1557 0.9752 0.3939 0.0093 B(:,:,6) = 0.0725 0.1907 0.2125 0.4685 0.9118 0.4302 0.5731 0.3077 0.7466 0.7765 0.5801 0.9925 0.1933 0.8881 0.0825 0.0272 0.7327 0.0360 0.1691 0.3511 0.3796 0.2089 0.6057 0.8891 0.3813 0.7812 0.7175 0.2675 0.3002 0.8021 0.5868 0.5693 0.8391 0.0382 0.1017 0.1084 0.6568 0.4986 0.3436 0.2224 0.3380 0.0023 0.2716 0.7236 0.0091 0.0885 0.5793 0.7745 0.4743 0.3615 0.0416 0.0914 0.9572 0.8503 0.1115 0.9398 0.0083 0.1961 0.9988 0.5983 0.5935 0.5740 0.6910 0.4855 0.1726 0.1964 0.8436 0.2729 0.5490 0.4355 0.4048 0.5113 0.6829 0.0124 0.9652 0.1754 0.4121 0.3397 0.2648 0.7671 0.4326 0.9627 0.7035 0.8106 0.2916 0.5512 0.1071 0.5628 0.0005 0.0648 0.6233 0.9024 0.2242 0.3915 0.9363 0.8905 0.0046 0.8877 0.9999 0.5897 B(:,:,7) = 0.8546 0.3930 0.5129 0.9541 0.5022 0.4063 0.4893 0.6388 0.4618 0.5280 0.3824 0.3121 0.8459 0.5554 0.4369 0.1266 0.9870 0.9459 0.2007 0.1679 0.8478 0.8957 0.7027 0.5233 0.3818 0.0934 0.4957 0.0077 0.8540 0.5686 0.9691 0.2864 0.1766 0.1872 0.9584 0.6344 0.2805 0.1943 0.8197 0.5761 0.9669 0.1314 0.5669 0.7965 0.7167 0.7562 0.8365 0.6533 0.4924 0.6264 0.8068 0.3985 0.8951 0.5827 0.6051 0.9697 0.8348 0.9617 0.3909 0.4525 0.7421 0.2108 0.0932 0.0691 0.2199 0.2531 0.6516 0.0247 0.6822 0.4619 0.5587 0.1347 0.4839 0.7917 0.4677 0.1906 0.8595 0.5049 0.3189 0.8986 0.4684 0.2379 0.9486 0.0904 0.6531 0.5434 0.5968 0.3980 0.4017 0.6285 0.8661 0.3920 0.0281 0.8991 0.8226 0.5701 0.7736 0.2190 0.2473 0.5870 B(:,:,8) = 0.7794 0.7451 0.7787 0.3769 0.8318 0.3353 0.5691 0.9151 0.1188 0.1182 0.9465 0.9506 0.7051 0.7426 0.1264 0.4966 0.1179 0.9431 0.0144 0.1205 0.0101 0.7785 0.1723 0.7542 0.2366 0.4372 0.0461 0.6942 0.0614 0.0458 0.6551 0.8059 0.4810 0.4192 0.2528 0.9911 0.4727 0.1691 0.1997 0.5269 0.7514 0.2480 0.2181 0.8283 0.5474 0.7865 0.2341 0.6013 0.5043 0.2605 0.6954 0.5264 0.9719 0.1928 0.1497 0.3040 0.6365 0.0136 0.2803 0.9540 0.4644 0.5988 0.0661 0.3913 0.8652 0.6414 0.3742 0.1130 0.8243 0.4529 0.2186 0.6515 0.9520 0.7450 0.4144 0.8183 0.0090 0.3182 0.9782 0.1896 0.4576 0.5486 0.4498 0.0435 0.6111 0.5821 0.0234 0.4816 0.4805 0.8032 0.8403 0.5152 0.2094 0.2122 0.2231 0.6554 0.6285 0.4975 0.3640 0.4906 B(:,:,9) = 0.2580 0.2345 0.9140 0.8143 0.6922 0.8130 0.1943 0.3596 0.5174 0.3210 0.6889 0.2209 0.9196 0.0735 0.8379 0.7154 0.7891 0.5249 0.2630 0.0349 0.2058 0.1143 0.1839 0.7579 0.7879 0.0221 0.8226 0.0245 0.7472 0.0289 0.5442 0.3993 0.9286 0.6931 0.8204 0.6828 0.7546 0.1049 0.1423 0.3770 0.8309 0.4359 0.4186 0.7460 0.0556 0.4903 0.1550 0.9262 0.2732 0.6763 0.4242 0.0870 0.6148 0.6864 0.6056 0.3251 0.7237 0.1189 0.2226 0.8350 0.6420 0.7693 0.8154 0.3482 0.7582 0.0540 0.8019 0.8165 0.3906 0.6527 0.1943 0.7328 0.4410 0.6023 0.7213 0.7187 0.2804 0.6953 0.7190 0.5972 0.3088 0.0897 0.9675 0.5495 0.2768 0.7920 0.4725 0.9469 0.4881 0.8350 0.5482 0.0630 0.5032 0.1611 0.4408 0.5711 0.2199 0.3322 0.2532 0.5723 B(:,:,10) = 0.7511 0.2010 0.9727 0.6810 0.8059 0.1507 0.4499 0.4333 0.1581 0.8638 0.7637 0.9027 0.6647 0.7187 0.3433 0.6867 0.1611 0.7310 0.5747 0.6369 0.1569 0.0538 0.3352 0.5143 0.2022 0.3828 0.0102 0.7851 0.2313 0.7658 0.1019 0.4450 0.9316 0.3002 0.8827 0.3054 0.1736 0.7725 0.0661 0.6766 0.2456 0.6320 0.8510 0.8037 0.2191 0.5302 0.6373 0.2577 0.6109 0.2401 0.5238 0.3588 0.2699 0.0422 0.8507 0.3228 0.2793 0.3843 0.9947 0.1507 0.8697 0.1176 0.8925 0.6924 0.6558 0.2472 0.3842 0.4923 0.7165 0.6738 0.6542 0.6457 0.2877 0.4351 0.8198 0.1721 ...

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

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

### Community Treasure Hunt

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

Start Hunting!