Cody

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

Solution 1029003

Submitted on 24 Oct 2016 by Dan Po
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) = Columns 1 through 9 0.7791 0.4665 0.1065 0.2902 0.3093 0.9899 0.8859 0.0577 0.1302 0.4981 0.4300 0.1490 0.4288 0.0596 0.9463 0.9962 0.3018 0.6801 0.4202 0.7216 0.8340 0 0.1160 0.6422 0.7582 0.8442 0.1742 0.1454 0.7076 0.8490 0.9494 0.0496 0.8571 0.6935 0.9635 0.9865 0.2249 0.3813 0.6860 0.8377 0.2824 0.5289 0.7306 0.9953 0.1338 0.7145 0.0038 0.2891 0.4069 0.7007 0.8687 0.6609 0.8878 0.6960 0.4477 0.7145 0.2261 0.5028 0.5955 0.7985 0.9448 0.3396 0.2715 0.1574 0.6317 0.8157 0.9691 0.8387 0.4626 0.5908 0.4740 0.3825 0.0480 0.5920 0.8859 0.6832 0.0064 0.3213 0.2930 0.6554 0.5795 0.5828 0.4475 0.4575 0.2007 0.1334 0.3850 0.8293 0.6977 0.7751 Column 10 0.9893 0.3095 0.5353 0.2387 0.2378 0.3647 0.2532 0.1001 0.7685 0.6785 A(:,:,2) = Columns 1 through 9 0.1236 0 0.5916 0.0443 0.5211 0.7657 0.3343 0.0400 0.2265 0.3445 0.5319 0.5103 0.5615 0.3507 0.8313 0.2039 0.1668 0.2370 0.8041 0.7856 0.9022 0.9258 0.8087 0.3421 0.6955 0.4634 0.8351 0.6600 0.0044 0.1958 0.4620 0.9088 0.1627 0.5512 0.1464 0.9598 0.6358 0.1439 0.2588 0.6747 0.1559 0.4128 0.5956 0.6165 0.2926 0.9661 0.8833 0.6491 0.5016 0.1652 0.7930 0.0433 0.6050 0.7759 0.7740 0.6954 0.4260 0.6805 0.9308 0.0160 0.1212 0.6183 0.5137 0.9215 0.1579 0.8662 0.3412 0.9387 0.3827 0.0969 0.4054 0.9105 0.5122 0.6332 0.6973 0.1554 0.5524 0.7152 0.3887 0.3543 0.2174 0.3728 0.0830 0.7799 0.4781 0.1840 0.7254 0.4732 0.5168 0.7812 Column 10 0.7427 0.7272 0.6232 0.5742 0.3301 0.6281 0.0463 0.9202 0.9595 0.1748 A(:,:,3) = Columns 1 through 9 0.5749 0.6641 0.6661 0.5856 0.7104 0.9818 0.2409 0.7604 0.7184 0.0071 0.6228 0.0505 0.7891 0.3674 0.4767 0.0783 0.2842 0.7276 0.6672 0.7692 0.5583 0.7595 0.1368 0.8484 0.1962 0.0838 0.3492 0.7295 0.8005 0.3862 0.6236 0.1653 0.7385 0.3228 0.6513 0.0068 0.6373 0.3779 0.1621 0.4060 0.2060 0 0.8056 0.3543 0.0534 0.1463 0.0208 0.3663 0.9898 0.5872 0.5932 0.3536 0.4108 0.4076 0.9953 0.0965 0.6357 0.6205 0.0639 0.9033 0.2007 0.2268 0.8060 0.8875 0.8845 0.1446 0.9626 0.0299 0.2481 0.6651 0.7798 0.2286 0.6886 0.2545 0.6446 0.9240 0.9838 0.6437 0.9646 0.9985 0.9474 0.8358 0.1317 0.7339 0.3064 0.3879 0.3598 0.0988 0.0479 0.0371 Column 10 0.7816 0.1632 0.7123 0.5147 0.9160 0.5565 0.7576 0.1593 0.2307 0.7574 A(:,:,4) = Columns 1 through 9 0.9136 0.7907 0.1881 0.0938 0.2004 0.9384 0.2027 0.5530 0.1248 0.8288 0.4695 0.9344 0.5474 0.5303 0.1086 0.0599 0.6675 0.3183 0.3240 0.0263 0.2389 0.9017 0.7147 0.1316 0.5570 0.2019 0.2658 0.6963 0.9342 0.7262 0.3656 0.7481 0.1730 0.1539 0.4474 0.1797 0.7324 0.3067 0.8345 0.3266 0.5578 0.0911 0.7960 0.6449 0.2755 0.4764 0.9881 0.2594 0.6139 0.9652 0.4377 0.6832 0.1542 0.7631 0.1341 0.0669 0.4245 0.3095 0.2608 0.8414 0.7598 0.7913 0.8693 0.3530 0.2218 0.4526 0.3287 0.3180 0.5674 0.9450 0.7005 0.7715 0.4462 0.6811 0.3474 0.3194 0.4996 0.4717 0.0640 0.8233 0.2361 0.2186 0.9036 0.9835 0.5158 0.5065 0.7562 0.4784 0.7937 0.8733 Column 10 0.0177 0.4269 0.3326 0.6745 0.7679 0.2629 0.1914 0.4387 0.5019 0.5096 A(:,:,5) = Columns 1 through 9 0.8413 0.8971 0.0986 0.9953 0.8429 0.3728 0.9534 0.0812 0.7883 0.0845 0.4529 0.3333 0.0837 0.8020 0.7365 0.7002 0.3808 0.8722 0.4080 0.7863 0.5797 0.6525 0.9317 0.4801 0.4697 0.1634 0.1264 0.3574 0.1453 0.6914 0.5866 0.4354 0.4847 0.4471 0.5329 0.2112 0.6863 0.8515 0.7329 0.6786 0.5723 0.3661 0.9558 0.9441 0.3052 0.8521 0.9034 0.6670 0.9271 0.2033 0.4728 0.1887 0.3818 0.4328 0.1266 0.4126 0.2214 0.2195 0.1473 0.0556 0.2604 0.1612 0.0283 0.7865 0.0472 0.5595 0.7353 0.1200 0.3694 0.1822 0.9706 0.6010 0.3179 0.4477 0.2970 0.9297 0.5257 0.4677 0.8172 0.4985 0.7515 0.7952 0.6223 0.2084 0.1968 0.9332 0.2006 0.2077 0.5311 0.8085 Column 10 0.5975 0.0848 0.3273 0.9609 0.4231 0.4270 0.3129 0.7260 0.6331 0.6311 A(:,:,6) = Columns 1 through 9 0.2083 0.9690 0.0758 0.0731 0.2698 0.8450 0.5120 0.8822 0.5910 0.0774 0.4450 0.8112 0.7916 0.9736 0.0930 0.7124 0.2476 0.6272 0.3446 0.4834 0.5477 0.0278 0.2309 0.9975 0.9990 0.4170 0.0991 0.4371 0.0167 0.2853 0.8221 0.5684 0.0263 0.5620 0.1288 0.3203 0.2540 0.4190 0.7538 0.4210 0.8243 0.7794 0.4151 0.7789 0.6433 0.8916 0.4424 0.4147 0.7728 0.1062 0.5234 0.8907 0.5255 0.3346 0.5547 0.4573 0.9823 0.4508 0.8014 0.3917 0.1041 0.6389 0.9175 0.4213 0.4476 0.6400 0.7446 0.5010 0.7845 0.6227 0.1321 0.1102 0.2275 0.5643 0.3074 0.2949 0.0364 0.2530 0.9188 0.7678 0.3913 0.0237 0.6175 0.5602 0.8772 0.3875 0.4684 0.9710 0.1602 0.0518 Column 10 0.2309 0.7231 0.0923 0.4353 0.6436 0.7293 0.1804 0.8562 0.4021 0.4036 A(:,:,7) = Columns 1 through 9 0.0327 0.6649 0.2151 0.9521 0.7259 0.4935 0.9211 0.7977 0.2607 0.2297 0.8449 0.3027 0.9120 0.3419 0.9137 0.5834 0.5326 0.4823 0.3888 0.6089 0.0255 0.0578 0.2888 0.6423 0.4361 0.7576 0.5385 0.2854 0.3189 0.6168 0.3516 0.3808 0.8850 0.4569 0.5379 0.0073 0.9790 0.0453 0.8699 0.7596 0.1055 0.7186 0.3079 0.8532 0.4108 0.2579 0.6251 0.2225 0.6672 0.8818 0.5112 0.9284 0.7155 0.5194 0.1643 0.9881 0.7599 0.1061 0.2267 0.9891 0.3145 0.4870 0.8757 0.3564 0.8350 0.1233 0.1982 0.3970 0.9986 0.8462 0.9238 0.2625 0.9673 0.8733 0.7940 0.8899 0.6951 0.7093 0.9313 0.8183 0.8163 0.7155 0.3975 0.5662 0.1887 0.0160 0.9251 0.9642 0.2306 0.8629 Column 10 0.0954 0.3080 0.8140 0.0143 0.9816 0.0484 0.0223 0.2917 0.8446 0.6599 A(:,:,8) = Columns 1 through 9 0.1993 0.0138 0.0616 0.5071 0.8972 0.1439 0.6278 0.5572 0.8835 0.8500 0.3758 0.8964 0.1406 0.4920 0.3552 0.8781 0.3790 0.0257 0.4434 0.5857 0.2883 0.3325 0.6850 0.7578 0.1511 0.0438 0.5020 0.2697 0.9286 0.7438 0.3978 0.2012 0.8729 0.2337 0.3875 0.7929 0.9942 0.0443 0.9387 0.7249 0.9187 0.1192 0.6203 0.7641 0.1971 0.3984 0.3120 0.2448 0.7657 0.3756 0.4777 0.1742 0.2719 0.0494 0.3036 0.8232 0.0671 0.1514 0.1042 0.5026 0.3810 0.1261 0.7293 0.3007 0.0776 0.9897 0.3092 0.9464 0.6243 0.0707 0.3565 0.4314 0.8466 0.2503 0.1066 0.8983 0.8985 0.5292 0.2167 0.0326 0.1913 0.6972 0.4365 0.6619 0.0671 0.9746 0.3743 0.4924 0.1702 0.1634 Column 10 0.6815 0.8229 0.2403 0.9500 0.0952 0.1134 0.3453 0.3171 0.9702 0.5351 A(:,:,9) = Columns 1 through 9 0.1194 0.2248 0.7623 0.4259 0.6546 0.9573 0.8075 0.2758 0.4827 0.2565 0.1275 0.6888 0.7197 0.1655 0.9618 0.2322 0.2493 0.2760 0.8484 0.2082 0.5528 0.0918 0.9806 0.9778 0.8159 0.1088 0.9028 0.9253 0.6533 0.9146 0.3118 0.7310 0.4030 0.3247 0.0742 0.8962 0.9407 0.0621 0.1511 0.4311 0.9071 0.0426 0.7641 0.5211 0.8188 0.4883 0.6200 0.9813 0.1359 0.9187 0.0258 0.7032 0.6080 0.8760 0.9507 0.9176 0.4615 0.5889 0.7519 0.1794 0.1247 0.4048 0.8071 0.6063 0.2671 0.4682 0.9878 0.0775 0.0359 0.0023 0.4422 0.8025 0.1033 0.2733 0.6442 0.8565 0.2041 0.9776 0.4548 0.6194 0.2222 0.8587 0.8514 0.7660 0.8757 0.7788 0.3965 0.0819 0.2317 0.8980 Column 10 0.5114 0.4322 0.9628 0.7658 0.7605 0.3523 0.7343 0.4416 0.3615 0.0403 A(:,:,10) = Columns 1 through 9 0.7914 0.3282 0.9388 0.8504 0.7447 0.7879 0.9402 0.0246 0.1906 0.9514 0.5914 0.8519 0.1860 0.9171 0.3809 0.5773 0.8328 0.9769 0.9266 0.1114 0.6055 0.9099 0.5916 0.2825 0.8059 0.6870 0.0751 0.2008 0.9370 0.3789 0.0094 0.1931 ...

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 = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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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17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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