Cody

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

Solution 2817928

Submitted on 11 Aug 2020 by Yin-Lung Wong
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.6772 0.4424 0.0356 0.1565 0.4718 0.6397 0.0114 0.8583 0.1452 0.5578 0.2059 0.4785 0.0608 0.8066 0.1080 0.7114 0.3528 0.1338 0.1465 0.3744 0.9484 0.7582 0.9567 0 0.4937 0.6498 0.1258 0.4145 0.7189 0.2109 0.2149 0.1088 0.0319 0.7885 0.0053 0.6468 0.1559 0.5934 0.7035 0.8862 0.4396 0.6932 0.6409 0.6688 0.4935 0.8073 0.4306 0.2219 0.8213 0.8312 0.9751 0.7980 0.2756 0.6999 0.2711 0.7122 0.7995 0.4032 0.0916 0.5222 0.0401 0.7028 0.9970 0.6360 0.3139 0.5300 0.4572 0.7797 0.3107 0.7215 0.6631 0.7498 0.9924 0.7547 0.6550 0.3433 0.1856 0.4439 0.0209 0.0949 0.4829 0.0038 0.8487 0.2554 0.2186 0.2310 0.3253 0.9940 0.7169 0.6535 0.4981 0.6495 0.0436 0.7108 0.6928 0.2185 0.2784 0.7447 0.6367 0.9781 A(:,:,2) = 0.0512 0 0.0981 0.8501 0.3682 0.5619 0.8035 0.4332 0.8915 0.8663 0.6282 0.0119 0.2509 0.3277 0.1101 0.6832 0.6369 0.0338 0.2935 0.6635 0.3474 0.9313 0.5893 0.3835 0.6877 0.5196 0.3670 0.7093 0.7014 0.3781 0.8364 0.0309 0.0148 0.1538 0.3278 0.4463 0.2002 0.2694 0.3197 0.9909 0.2545 0.2058 0.8825 0.2759 0.8686 0.2447 0.2972 0.1140 0.7792 0.2791 0.4260 0.4793 0.7807 0.3301 0.7394 0.4170 0.6857 0.0506 0.7479 0.6735 0.8564 0.0084 0.7109 0.0065 0.9332 0.1178 0.5928 0.7831 0.6404 0.9690 0.0216 0.7412 0.2924 0.2563 0.9744 0.9374 0.3870 0.2930 0.0222 0.8825 0.0473 0.0256 0.7030 0.3071 0.3525 0.1837 0.0592 0.7910 0.8035 0.6599 0.6778 0.6596 0.9449 0.3989 0.5753 0.9565 0.1708 0.8556 0.1232 0.1016 A(:,:,3) = 0.9004 0.1004 0.8877 0.9689 0.4819 0.0229 0.4220 0.6748 0.3525 0.7555 0.7094 0.0824 0.5955 0.0697 0.5542 0.7148 0.5613 0.9341 0.1137 0.4902 0.9691 0.1548 0.1200 0.2273 0.1883 0.9207 0.2021 0.4025 0.2679 0.0187 0.1322 0.4118 0.7961 0.7247 0.6574 0.1356 0.3517 0.7436 0.9677 0.1666 0.8999 0.1833 0.5005 0.1009 0.0779 0 0.1705 0.6059 0.6898 0.8387 0.6345 0.1043 0.1743 0.1136 0.2782 0.0937 0.2323 0.6822 0.1495 0.5619 0.7405 0.3503 0.1157 0.6043 0.2894 0.0525 0.9558 0.7303 0.4342 0.0011 0.9006 0.1441 0.2569 0.2151 0.7610 0.3042 0.5923 0.5722 0.4529 0.6477 0.4566 0.3129 0.6843 0.5340 0.1350 0.3789 0.4428 0.1846 0.7962 0.1203 0.3873 0.5553 0.0155 0.3883 0.7110 0.0202 0.0215 0.6554 0.5490 0.7476 A(:,:,4) = 0.5624 0.7855 0.7507 0.1118 0.8592 0.1754 0.2204 0.6499 0.5883 0.2774 0.2311 0.3885 0.3629 0.0452 0.2562 0.6488 0.2245 0.4555 0.2352 0.7174 0.8208 0.2038 0.9913 0.9952 0.8662 0.0794 0.8327 0.2542 0.2430 0.9619 0.1995 0.2062 0.5599 0.3108 0.0401 0.3879 0.3505 0.0591 0.9988 0.6717 0.1356 0.4426 0.2330 0.3603 0.2061 0.9540 0.9189 0.3795 0.7532 0.0416 0.2673 0.0757 0.4479 0.0272 0.0271 0.1178 0.7839 0.9777 0.6532 0.0221 0.9395 0.9229 0.6172 0.5066 0.1489 0.8812 0.1912 0.1400 0.2076 0.3091 0.0820 0.5692 0.8031 0.0359 0.3755 0.3108 0.4474 0.8258 0.6330 0.2120 0.7203 0.2057 0.5469 0.9212 0.1794 0.4904 0.7172 0.9688 0.8096 0.9034 0.4307 0.7203 0.2337 0.9433 0.9552 0.3346 0.7595 0.1001 0.3691 0.6625 A(:,:,5) = 0.8561 0.5126 0.7670 0.7168 0.4341 0.6754 0.4903 0.2143 0.8864 0.8625 0.8658 0.9654 0.1667 0.8985 0.6004 0.8582 0.2744 0.9683 0.3286 0.0840 0.6844 0.6765 0.2757 0.0904 0.7966 0.7183 0.1682 0.4270 0.4876 0.1906 0.1169 0.8487 0.7835 0.1063 0.4627 0.5003 0.2455 0.1984 0.3222 0.6959 0.3844 0.5287 0.3583 0.7409 0.3297 0.5730 0.5020 0.5094 0.5547 0.4788 0.8134 0.7754 0.5371 0.9923 0.9817 0.8517 0.0497 0.0337 0.2120 0.6665 0.3059 0.5107 0.7124 0.0248 0.4407 0.2184 0.4767 0.5014 0.5042 0.0436 0.1721 0.6880 0.7208 0.8893 0.4277 0.1052 0.9678 0.9966 0.3560 0.0948 0.8786 0.4779 0.1948 0.0901 0.4619 0.4162 0.1147 0.9566 0.4318 0.3555 0.5383 0.5710 0.8774 0.1343 0.4583 0.2223 0.9670 0.6194 0.3888 0.7934 A(:,:,6) = 0.4408 0.6797 0.9211 0.0940 0.0717 0.5688 0.8224 0.4910 0.0627 0.6066 0.2042 0.9164 0.9851 0.2483 0.0459 0.6909 0.4763 0.4705 0.4720 0.8978 0.6683 0.0985 0.1990 0.4597 0.0157 0.7528 0.4993 0.5170 0.4739 0.2461 0.9305 0.3894 0.8600 0.1355 0.2870 0.6240 0.3872 0.7901 0.4584 0.6688 0.8690 0.0206 0.8560 0.1112 0.6703 0.4118 0.1094 0.4537 0.4941 0.0114 0.1263 0.2233 0.5071 0.2051 0.7538 0.5002 0.7314 0.6743 0.3320 0.0707 0.2297 0.6305 0.3282 0.0294 0.9069 0.3323 0.3624 0.2140 0.1490 0.2888 0.7313 0.3795 0.7266 0.8046 0.4788 0.0980 0.5409 0.3144 0.8888 0.1817 0.9498 0.7727 0.5847 0.7901 0.1203 0.3578 0.2584 0.6733 0.4745 0.2536 0.6943 0.5843 0.9458 0.9814 0.0162 0.5494 0.7731 0.5878 0.3691 0.4592 A(:,:,7) = 0.7882 0.9347 0.4295 0.0471 0.6431 0.9599 0.7948 0.1345 0.0393 0.8590 0.2625 0.7908 0.2999 0.7792 0.5887 0.0388 0.5518 0.6568 0.6589 0.0600 0.3878 0.7282 0.8480 0.3638 0.9653 0.3737 0.1765 0.3359 0.4944 0.9359 0.9694 0.0788 0.8341 0.8592 0.0898 0.7232 0.1423 0.8986 0.8623 0.9718 0.3252 0.6960 0.5129 0.4222 0.0845 0.5706 0.2987 0.2834 0.6996 0.4710 0.3536 0.1655 0.1617 0.2865 0.1322 0.6690 0.5809 0.4703 0.8095 0.7457 0.7324 0.9859 0.3363 0.3817 0.7106 0.9143 0.0245 0.6004 0.9509 0.9691 0.0781 0.2762 0.0143 0.3770 0.6025 0.4902 0.6979 0.4480 0.6673 0.6010 0.8998 0.1507 0.0768 0.3181 0.2138 0.3999 0.1220 0.3203 0.3420 0.2344 0.6770 0.9759 0.6239 0.7066 0.8494 0.9372 0.0169 0.0351 0.8935 0.5995 A(:,:,8) = 0.2729 0.6783 0.2614 0.1062 0.1072 0.0184 0.3819 0.7710 0.6928 0.4066 0.3265 0.9585 0.3638 0.5516 0.7455 0.8534 0.6900 0.6403 0.8735 0.3468 0.3411 0.6198 0.6871 0.5095 0.7890 0.3939 0.7466 0.7157 0.9093 0.2267 0.0085 0.0586 0.6197 0.9954 0.2303 0.9756 0.0330 0.5455 0.4358 0.9101 0.9645 0.8164 0.0946 0.7027 0.2061 0.2562 0.9091 0.9322 0.3354 0.3279 0.0334 0.7116 0.1938 0.7461 0.8271 0.9947 0.8298 0.0520 0.7120 0.3964 0.4140 0.2026 0.7283 0.8900 0.9855 0.1329 0.3394 0.0223 0.4494 0.0354 0.9021 0.9230 0.5174 0.5882 0.6462 0.1568 0.6382 0.2003 0.4513 0.2150 0.8450 0.7622 0.0887 0.3477 0.9748 0.7319 0.5832 0.3117 0.4986 0.1655 0.5379 0.7813 0.9247 0.6249 0.5170 0.6601 0.1076 0.4436 0.5689 0.1355 A(:,:,9) = 0.5160 0.3992 0.3562 0.7119 0.5383 0.8001 0.7739 0.9841 0.6872 0.0304 0.9755 0.3069 0.4042 0.1414 0.4475 0.5114 0.7211 0.3826 0.4115 0.3387 0.2029 0.9197 0.2099 0.6426 0.4926 0.8634 0.3217 0.2446 0.1292 0.5132 0.5436 0.7066 0.4639 0.8928 0.8214 0.4170 0.4930 0.6314 0.0139 0.6573 0.7069 0.4511 0.8528 0.0328 0.2000 0.0269 0.9572 0.1502 0.9097 0.3979 0.4506 0.3117 0.2156 0.7417 0.1851 0.0398 0.0282 0.4792 0.3647 0.9772 0.0928 0.8220 0.7379 0.4961 0.8864 0.2219 0.0815 0.6656 0.8944 0.0994 0.4350 0.6878 0.9956 0.4726 0.8912 0.9607 0.5332 0.3043 0.9703 0.2987 0.4072 0.3554 0.9483 0.7697 0.9660 0.7993 0.7016 0.0802 0.1755 0.8960 0.0173 0.4732 0.3147 0.7375 0.4281 0.0230 0.3274 0.0781 0.9869 0.7648 A(:,:,10) = 0.8109 0.3816 0.7944 0.7489 0.0203 0.0357 0.8103 0.7566 0.1033 0.3846 0.7131 0.0184 0.3040 0.6657 0.0371 0.4876 0.3769 0.5663 0.6679 0.7651 0.4169 0.2498 0.6524 0.2759 0.8712 0.3898 0.6492 0.4188 0.4264 0.6781 0.0605 0.6539 0.2769 0.4004 0.3643 0.6999 0.1779 0.5699 0.9342 0.3944 0.0534 0.9356 0.8038 0.4201 0.4303 0.4428 0.2787 0.8260 0.0415 0.9925 0.1701 0.4783 0.6356 0.8300 0.1922 0.5729 0.7970 0.2341 0.8011 0.1092 0.8973 0.5462 0.1986 0.8086 0.2471 0.3734 0.6860 0.8263 0.6915 0.6288 0.1714 0.6838 0.7110 0.4292 0.4477 0.9780 ...

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