Cody

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

Solution 1117801

Submitted on 8 Feb 2017 by Angela Labianca-Campbell
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) = Columns 1 through 9 0.5480 0.2119 0.0102 0.1604 0.3533 0.2281 0.7125 0.2779 0.5004 0.1016 0.8636 0.0136 0.9394 0.3272 0.6556 0.4278 0.5090 0.4347 0.3862 0.9918 0.5834 0 0.0662 0.2874 0.6430 0.1270 0.9049 0.9915 0.2947 0.2928 0.6822 0.4957 0.6460 0.7787 0.2819 0.2706 0.8453 0.1777 0.1352 0.7455 0.8965 0.1136 0.7224 0.7303 0.7219 0.5244 0.2045 0.3674 0.0117 0.5015 0.2075 0.0557 0.3167 0.7610 0.1579 0.1985 0.8919 0.3418 0.0674 0.7142 0.9527 0.8624 0.6331 0.6281 0.7075 0.2584 0.7202 0.1987 0.9984 0.1280 0.5337 0.1713 0.1880 0.3737 0.1627 0.5549 0.2153 0.8396 0.9108 0.6008 0.8973 0.6453 0.4992 0.5305 0.0535 0.9756 0.7693 0.9007 0.2901 0.7534 Column 10 0.2161 0.7087 0.5754 0.5464 0.1071 0.1000 0.4647 0.9632 0.9135 0.4840 B(:,:,2) = Columns 1 through 9 0.0458 0 0.6518 0.3154 0.6451 0.4212 0.4180 0.7655 0.1728 0.3958 0.8176 0.1988 0.3266 0.8366 0.9938 0.5156 0.1729 0.5343 0.9865 0.5201 0.8228 0.7215 0.0032 0.8206 0.0269 0.2868 0.6797 0.6750 0.9462 0.2135 0.2062 0.4056 0.5708 0.9915 0.8748 0.3703 0.5249 0.6500 0.6097 0.9175 0.9752 0.8948 0.6074 0.5016 0.5793 0.3493 0.7625 0.7566 0.5646 0.2198 0.4383 0.1771 0.9982 0.3206 0.6775 0.7621 0.2422 0.2200 0.0432 0.0761 0.2823 0.3465 0.3023 0.1891 0.1635 0.7419 0.0634 0.6729 0.4521 0.7792 0.8391 0.7400 0.6201 0.0197 0.9202 0.7937 0.8813 0.3805 0.5229 0.5059 0.8492 0.4742 0.2469 0.1083 0.4372 0.0635 0.5514 0.1180 0.6914 0.0518 Column 10 0.1885 0.6380 0.2685 0.7843 0.9803 0.9704 0.5277 0.5549 0.8553 0.6936 B(:,:,3) = Columns 1 through 9 0.0822 0.3580 0.4607 0.1663 0.9028 0.7814 0.8556 0.7782 0.2540 0.3720 0.5028 0.3199 0.3572 0.0371 0.3956 0.9353 0.2668 0.0231 0.8919 0.0324 0.4203 0.7829 0.6025 0.2881 0.3268 0.8771 0.2585 0.6576 0.3698 0.2690 0.2752 0.9144 0.5099 0.1250 0.6427 0.2672 0.1857 0.7420 0.9359 0.7317 0.8984 0 0.0770 0.4057 0.5761 0.1987 0.8788 0.0713 0.2198 0.8075 0.8081 0.3936 0.2826 0.6901 0.1052 0.5154 0.1463 0.4051 0.3981 0.3692 0.9929 0.8590 0.7474 0.4784 0.8424 0.4563 0.4429 0.2888 0.2356 0.9000 0.2008 0.9734 0.7915 0.5603 0.8491 0.6631 0.2462 0.3440 0.3660 0.2103 0.5731 0.8251 0.4825 0.9966 0.8474 0.6904 0.8298 0.3863 0.1253 0.0071 Column 10 0.9375 0.2871 0.7064 0.2124 0.5107 0.9281 0.2030 0.9279 0.0251 0.7162 B(:,:,4) = Columns 1 through 9 0.3951 0.9718 0.1255 0.9993 0.4236 0.8662 0.2599 0.7023 0.8367 0.6854 0.5053 0.3252 0.8737 0.7645 0.0002 0.9846 0.3838 0.3826 0.8738 0.5369 0.1675 0.8876 0.2690 0.0383 0.7889 0.8346 0.2063 0.1766 0.1044 0.6962 0.1101 0.1887 0.0857 0.4764 0.7652 0.9640 0.6074 0.8283 0.8255 0.1105 0.2503 0.8910 0.0039 0.7989 0.8980 0.9615 0.3365 0.2412 0.9368 0.7890 0.2595 0.1584 0.3112 0.5137 0.4680 0.1388 0.2701 0.9302 0.2432 0.4743 0.0015 0.2457 0.0679 0.4685 0.4809 0.8700 0.9185 0.4199 0.9054 0.2197 0.2395 0.8375 0.3664 0.2116 0.3678 0.5475 0.8791 0.5643 0.4917 0.3927 0.5637 0.2711 0.9808 0.9085 0.6003 0.2861 0.4661 0.7883 0.2884 0.4307 Column 10 0.3005 0.7024 0.7428 0.7546 0.4280 0.4888 0.9811 0.8489 0.7361 0.0877 B(:,:,5) = Columns 1 through 9 0.3407 0.0351 0.8815 0.5369 0.2657 0.8237 0.1642 0.2408 0.9764 0.2455 0.7596 0.0007 0.1208 0.5120 0.6069 0.0461 0.7560 0.4380 0.0068 0.4391 0.5006 0.9903 0.3475 0.4415 0.3030 0.1878 0.9885 0.0168 0.5128 0.8271 0.1003 0.9168 0.2784 0.1875 0.4816 0.3672 0.8830 0.3295 0.9321 0.8431 0.5743 0.6597 0.4949 0.7552 0.4513 0.6189 0.6604 0.6016 0.8872 0.8654 0.7809 0.6276 0.6015 0.2530 0.8188 0.4801 0.6829 0.8270 0.8059 0.6734 0.0229 0.9784 0.3656 0.3647 0.2134 0.6360 0.9465 0.1852 0.9512 0.3755 0.2904 0.9746 0.8401 0.9893 0.1140 0.3153 0.8010 0.0710 0.9241 0.4901 0.8527 0.8360 0.3468 0.2495 0.3123 0.7039 0.9575 0.8682 0.1496 0.2795 Column 10 0.4235 0.0257 0.4234 0.0872 0.2009 0.5475 0.3684 0.0810 0.5687 0.3711 B(:,:,6) = Columns 1 through 9 0.0876 0.5092 0.1894 0.9031 0.4452 0.5324 0.6555 0.9601 0.9311 0.3590 0.8199 0.8229 0.1847 0.6805 0.3817 0.1103 0.1887 0.7463 0.5674 0.5906 0.7536 0.8711 0.6813 0.4790 0.9231 0.4030 0.5331 0.4823 0.2836 0.9881 0.5169 0.8822 0.4034 0.5067 0.8331 0.7917 0.3814 0.4315 0.9636 0.8386 0.4375 0.7393 0.8293 0.8727 0.1796 0.3760 0.7651 0.9062 0.6736 0.2720 0.2402 0.1816 0.5534 0.2623 0.2170 0.5849 0.1915 0.6077 0.6305 0.3742 0.0106 0.0478 0.2249 0.4896 0.5076 0.3001 0.5083 0.5340 0.5079 0.6526 0.8063 0.5005 0.0316 0.0844 0.2763 0.3578 0.1304 0.1126 0.8075 0.1344 0.1641 0.5002 0.9722 0.1534 0.6691 0.4850 0.7582 0.3464 0.4594 0.5226 Column 10 0.1089 0.1537 0.0158 0.3286 0.1237 0.5972 0.9519 0.4603 0.8385 0.8761 B(:,:,7) = Columns 1 through 9 0.3143 0.7559 0.4499 0.9544 0.1134 0.7616 0.3794 0.0987 0.6013 0.4087 0.8000 0.0706 0.0916 0.5751 0.6094 0.9461 0.2824 0.5694 0.0475 0.6498 0.8269 0.9207 0.6667 0.6793 0.1064 0.8750 0.4581 0.2577 0.0005 0.3972 0.2925 0.7496 0.3743 0.0199 0.0256 0.7830 0.5252 0.6442 0.8647 0.4336 0.5748 0.0123 0.1537 0.5924 0.4918 0.7257 0.2237 0.1475 0.2684 0.9089 0.5188 0.1522 0.4048 0.5273 0.7038 0.4749 0.2826 0.2841 0.6857 0.4269 0.4593 0.7881 0.6494 0.8576 0.9550 0.7514 0.4560 0.6833 0.9094 0.9185 0.9417 0.1407 0.0397 0.9249 0.1634 0.2007 0.6766 0.8827 0.2853 0.0415 0.5469 0.7454 0.4190 0.6973 0.1104 0.6233 0.5425 0.0593 0.7262 0.4861 Column 10 0.1866 0.9728 0.4682 0.7872 0.9816 0.8846 0.5717 0.4655 0.5193 0.9593 B(:,:,8) = Columns 1 through 9 0.2443 0.6533 0.5474 0.8369 0.4471 0.5219 0.4371 0.6885 0.6056 0.5755 0.9371 0.7273 0.5695 0.7987 0.1961 0.2551 0.7491 0.2092 0.3825 0.8429 0.4843 0.9402 0.6703 0.7576 0.3748 0.6245 0.3051 0.1533 0.9689 0.1157 0.2760 0.6156 0.8355 0.0515 0.8930 0.5172 0.8521 0.8956 0.0709 0.9145 0.2809 0.5536 0.5207 0.4372 0.5625 0.1201 0.7335 0.2179 0.7183 0.3516 0.6876 0.8646 0.5335 0.9282 0.3883 0.3186 0.6976 0.1422 0.3547 0.1030 0.6726 0.0327 0.5947 0.6904 0.8294 0.6210 0.1650 0.9918 0.4290 0.1210 0.0744 0.3326 0.8877 0.4885 0.7432 0.6368 0.5123 0.0804 0.4432 0.8991 0.2291 0.5165 0.7308 0.8852 0.2167 0.9446 0.5458 0.4132 0.9688 0.4212 Column 10 0.7898 0.0674 0.1417 0.2796 0.1539 0.2561 0.1957 0.6854 0.5607 0.4941 B(:,:,9) = Columns 1 through 9 0.1835 0.7211 0.2602 0.0700 0.6617 0.3937 0.3601 0.4879 0.2751 0.7615 0.4836 0.5165 0.8363 0.2933 0.6810 0.5790 0.4946 0.2158 0.4979 0.6121 0.5949 0.7187 0.0163 0.7513 0.4009 0.1116 0.1858 0.1739 0.1642 0.5546 0.5914 0.9681 0.7399 0.7814 0.2533 0.1754 0.5667 0.9315 0.2428 0.8928 0.5131 0.3043 0.9492 0.9149 0.0710 0.9360 0.6507 0.4088 0.3769 0.9499 0.4822 0.7134 0.5216 0.6450 0.0813 0.3529 0.4816 0.3319 0.6556 0.5540 0.8060 0.1357 0.7210 0.4538 0.5452 0.0207 0.5076 0.8822 0.9993 0.1494 0.6069 0.3593 0.7978 0.2092 0.7215 0.7943 0.6765 0.0444 0.6498 0.8977 0.2730 0.9365 0.5163 0.4738 0.7512 0.2908 0.7336 0.9592 0.2413 0.2141 Column 10 0.5965 0.9342 0.6275 0.8688 0.3201 0.9887 0.4255 0.6984 0.2596 0.7638 B(:,:,10) = Columns 1 through 9 0.8963 0.5917 0.9199 0.1082 0.5847 0.5654 0.1857 0.6522 0.9642 0.0391 0.2428 0.0751 0.1977 0.8143 0.9650 0.3720 0.2321 0.0100 0.6853 0.9347 0.5904 0.5519 0.4119 0.9150 0.4990 0.6277 0.9622 0.7357 0.8611 0.6191 0.8251 0.0273 ...

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

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