Cody

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

Solution 1761183

Submitted on 25 Mar 2019 by Oliver Braatz
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.5013 0.2034 0.7545 0.2745 0.6784 0.3612 0.5608 0.0373 0.1883 0.9096 0.8362 0.6156 0.8043 0.2393 0.2989 0.1118 0.4992 0.0400 0.0484 0.3295 0.9743 0.2580 0.7211 0 0.7808 0.0944 0.4114 0.7948 0.8801 0.5115 0.6569 0.2918 0.0739 0.0924 0.8588 0.7856 0.0058 0.0924 0.0707 0.8202 0.7790 0.7506 0.2891 0.1083 0.8554 0.7252 0.2197 0.5889 0.9336 0.3942 0.9064 0.0278 0.9441 0.1090 0.2832 0.1708 0.9286 0.6988 0.3007 0.3392 0.9524 0.7370 0.5365 0.6952 0.4754 0.4644 0.7972 0.5044 0.3403 0.7340 0.6602 0.0125 0.8445 0.3531 0.4586 0.9903 0.1111 0.5609 0.8775 0.5129 0.5548 0.4373 0.4085 0.6939 0.0293 0.2597 0.3777 0.0787 0.5370 0.8831 0.5589 0.0857 0.3261 0.3693 0.4767 0.4204 0.8520 0.0600 0.8557 0.3265 A(:,:,2) = 0.3471 0 0.1767 0.3516 0.3041 0.8284 0.7600 0.3777 0.0914 0.7079 0.6875 0.5007 0.8561 0.2884 0.6707 0.3766 0.5588 0.3030 0.9235 0.0891 0.1624 0.6806 0.1700 0.8815 0.2992 0.6607 0.2956 0.1608 0.7475 0.5683 0.4905 0.4350 0.5318 0.4701 0.3641 0.6275 0.6682 0.4555 0.2194 0.2955 0.2015 0.3298 0.5775 0.3729 0.3099 0.6789 0.8966 0.6078 0.2994 0.1731 0.1863 0.1082 0.7245 0.7066 0.5254 0.6094 0.3316 0.8676 0.1611 0.7962 0.7446 0.9945 0.1226 0.0512 0.0148 0.7398 0.8973 0.7817 0.9230 0.9547 0.7235 0.6039 0.8412 0.1263 0.5201 0.4049 0.6503 0.9891 0.2604 0.4322 0.9847 0.0739 0.3782 0.9142 0.7075 0.1596 0.8644 0.9836 0.3367 0.9484 0.5246 0.3419 0.8155 0.7731 0.0898 0.2834 0.7910 0.0425 0.8191 0.0320 A(:,:,3) = 0.5196 0.4046 0.3223 0.9560 0.5116 0.6755 0.7504 0.4321 0.3230 0.9423 0.7908 0.7615 0.3460 0.1444 0.9735 0.1212 0.0320 0.7194 0.7684 0.3213 0.1342 0.0839 0.2205 0.5760 0.6589 0.2262 0.9528 0.1848 0.8256 0.6627 0.4496 0.6040 0.1132 0.7943 0.1165 0.0005 0.9663 0.7392 0.4438 0.9107 0.9588 0.5283 0.8796 0.8029 0.0724 0 0.9772 0.4446 0.3616 0.8820 0.4880 0.8859 0.8518 0.9715 0.6686 0.5213 0.0857 0.6530 0.5350 0.0490 0.4370 0.9219 0.9074 0.0855 0.5476 0.1858 0.1881 0.6203 0.8727 0.6656 0.6392 0.1177 0.8293 0.3728 0.0194 0.5009 0.5934 0.7209 0.9639 0.4899 0.0451 0.3450 0.0148 0.7530 0.0809 0.4705 0.8307 0.4611 0.3554 0.1475 0.1681 0.6354 0.2670 0.1926 0.0510 0.8790 0.4709 0.2806 0.7632 0.0290 A(:,:,4) = 0.0356 0.9074 0.1310 0.5573 0.3046 0.9231 0.1761 0.3435 0.9704 0.2906 0.3801 0.3348 0.6118 0.6473 0.7919 0.2738 0.0438 0.5027 0.0816 0.7891 0.8143 0.9009 0.1509 0.5892 0.2533 0.9966 0.5669 0.9084 0.7434 0.8105 0.0867 0.7701 0.5682 0.7077 0.2173 0.9736 0.4911 0.1458 0.5990 0.0901 0.6177 0.2757 0.9555 0.8333 0.7130 0.9250 0.6913 0.1880 0.8658 0.5994 0.8646 0.7268 0.1233 0.6688 0.7596 0.9019 0.5348 0.6848 0.5335 0.9858 0.2438 0.5317 0.6855 0.3851 0.9954 0.0306 0.7030 0.8413 0.5497 0.8699 0.7670 0.9821 0.2022 0.3352 0.5255 0.1801 0.1669 0.9566 0.8049 0.5563 0.7973 0.7877 0.2979 0.3599 0.5661 0.7841 0.9038 0.9255 0.3498 0.0316 0.7362 0.2035 0.9446 0.5070 0.1437 0.9260 0.7953 0.9248 0.8037 0.5316 A(:,:,5) = 0.1151 0.2758 0.6345 0.8111 0.9190 0.7663 0.7327 0.1248 0.4126 0.8768 0.2802 0.3468 0.3982 0.9597 0.4184 0.1274 0.8808 0.5831 0.9877 0.1841 0.0203 0.1825 0.0104 0.4904 0.3077 0.2333 0.5965 0.3986 0.8501 0.2307 0.7745 0.8483 0.7030 0.6615 0.4033 0.1807 0.0236 0.3152 0.6919 0.6894 0.6526 0.2375 0.4030 0.6380 0.0455 0.5403 0.1186 0.9488 0.7454 0.2415 0.3862 0.0748 0.3334 0.0996 0.7183 0.6983 0.7412 0.1089 0.5862 0.7731 0.6248 0.1768 0.5468 0.8888 0.6896 0.5678 0.5344 0.8774 0.5380 0.6235 0.6957 0.0636 0.7486 0.7334 0.3677 0.5391 0.1192 0.9403 0.9379 0.3750 0.9533 0.1729 0.5644 0.9107 0.4225 0.2324 0.5808 0.4026 0.5370 0.1262 0.1533 0.3624 0.1064 0.5867 0.1439 0.1870 0.1538 0.0868 0.6446 0.4559 A(:,:,6) = 0.2526 0.6371 0.9436 0.8591 0.1765 0.4918 0.3864 0.3930 0.0473 0.8532 0.3417 0.0257 0.8291 0.5447 0.4274 0.0669 0.8830 0.4964 0.0561 0.2875 0.3429 0.0261 0.5936 0.0392 0.8477 0.9734 0.6244 0.4074 0.6995 0.3373 0.0700 0.5867 0.9510 0.0224 0.4703 0.4589 0.8741 0.2501 0.2252 0.4001 0.3854 0.6120 0.0108 0.8812 0.8712 0.0757 0.5331 0.2062 0.9762 0.4081 0.5337 0.3999 0.8426 0.1301 0.2317 0.5137 0.7284 0.9586 0.7258 0.4330 0.4170 0.2683 0.1081 0.8458 0.2430 0.0222 0.7062 0.6387 0.4581 0.5565 0.7725 0.2184 0.6792 0.5131 0.7417 0.8793 0.5097 0.5679 0.0114 0.3055 0.1945 0.6558 0.3367 0.8780 0.2860 0.8352 0.2612 0.1623 0.6785 0.0943 0.0804 0.5309 0.5377 0.8875 0.4604 0.6272 0.2554 0.6808 0.5528 0.5916 A(:,:,7) = 0.4445 0.9995 0.8147 0.6302 0.6370 0.5916 0.6500 0.6995 0.6269 0.2647 0.6785 0.4680 0.4864 0.2344 0.7703 0.4283 0.7215 0.8759 0.6684 0.9371 0.4331 0.9868 0.5685 0.7689 0.8592 0.5549 0.0217 0.3530 0.4162 0.5118 0.2760 0.8683 0.2086 0.0273 0.8701 0.7783 0.4927 0.4348 0.4398 0.3432 0.7031 0.2719 0.0935 0.0225 0.1839 0.6162 0.7561 0.7524 0.0410 0.6352 0.2812 0.4969 0.3240 0.6374 0.5280 0.6410 0.9083 0.9211 0.8547 0.1787 0.8206 0.0422 0.2143 0.4274 0.1598 0.1610 0.5721 0.5969 0.6511 0.4626 0.6974 0.7278 0.0590 0.3330 0.5909 0.4717 0.4733 0.6016 0.9643 0.8105 0.1471 0.7419 0.1545 0.1680 0.5763 0.9748 0.0462 0.3298 0.5860 0.1283 0.6595 0.3903 0.3376 0.6532 0.8700 0.1257 0.5139 0.0333 0.0250 0.0619 A(:,:,8) = 0.1461 0.0689 0.3295 0.4152 0.6477 0.0794 0.5320 0.6738 0.3911 0.4847 0.6461 0.9755 0.8445 0.7331 0.3143 0.5539 0.9645 0.3976 0.2174 0.5826 0.5295 0.4210 0.4237 0.6513 0.5867 0.4322 0.1289 0.0738 0.9223 0.6058 0.4130 0.1627 0.4621 0.9895 0.9726 0.0838 0.4830 0.3868 0.3059 0.5286 0.1991 0.8392 0.7256 0.1069 0.7751 0.5078 0.1819 0.9876 0.1336 0.8596 0.6807 0.8131 0.9351 0.8526 0.8222 0.8744 0.8695 0.1802 0.4087 0.3661 0.2340 0.7420 0.8850 0.0473 0.1171 0.0068 0.4652 0.4756 0.8764 0.7695 0.1672 0.8981 0.9427 0.1932 0.6738 0.1312 0.8727 0.6877 0.4118 0.6885 0.0000 0.6454 0.0259 0.2341 0.7771 0.2330 0.3580 0.9075 0.9901 0.7880 0.4244 0.1958 0.7104 0.5581 0.7325 0.2034 0.2433 0.3043 0.1444 0.9598 A(:,:,9) = 0.8256 0.3727 0.3663 0.5834 0.7724 0.0789 0.1822 0.1780 0.0202 0.7166 0.6740 0.1293 0.3349 0.2626 0.9205 0.1488 0.0583 0.9639 0.9647 0.0111 0.8811 0.7378 0.9095 0.1240 0.6287 0.0436 0.5503 0.6472 0.1849 0.3198 0.8597 0.5786 0.3500 0.7790 0.9708 0.1954 0.7591 0.4827 0.1146 0.7473 0.7785 0.0012 0.1466 0.1534 0.0637 0.7819 0.6235 0.5758 0.2354 0.5645 0.7856 0.0209 0.8830 0.3902 0.1548 0.4464 0.8238 0.3619 0.4193 0.8433 0.2938 0.0116 0.4881 0.7488 0.7677 0.4321 0.2892 0.0924 0.0654 0.3747 0.0847 0.1412 0.4298 0.7776 0.1659 0.7772 0.4505 0.6583 0.4574 0.6291 0.9394 0.7712 0.0565 0.1062 0.7276 0.6050 0.2055 0.9722 0.9458 0.9609 0.3113 0.9726 0.9609 0.2055 0.6194 0.3633 0.2367 0.6576 0.6626 0.5389 A(:,:,10) = 0.5949 0.9735 0.3696 0.3800 0.1757 0.6263 0.9101 0.3385 0.0217 0.1195 0.9267 0.2683 0.9121 0.3039 0.2665 0.1783 0.3351 0.5876 0.1822 0.7417 0.6686 0.1077 0.3380 0.6231 0.5329 0.8710 0.5110 0.5400 0.4026 0.0341 0.4264 0.7389 0.6543 0.8267 0.9317 0.5581 0.6600 0.2217 0.2104 0.5078 0.0947 0.4953 0.1972 0.8817 0.1580 0.3838 0.0903 0.6150 0.8478 0.9230 0.3126 0.3038 0.4587 0.0662 0.3225 0.0656 0.2737 0.4061 0.2805 0.5221 0.8247 0.8832 0.1868 0.9121 0.3418 0.3175 0.7964 0.1324 0.2234 0.8593 0.5789 0.2976 0.4172 0.2835 0.5556 0.0451 ...

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