Cody

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

Solution 665789

Submitted on 5 May 2015 by Jonathan Campelli
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
%% test 1 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

2   Pass
%% test 2 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

3   Pass
%% test 3 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 = []

4   Pass
%% test 4 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

5   Pass
%% test 5 with a multidimensional array 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.4615 0.2520 0.2879 0.4484 0.1804 0.2462 0.4419 0.3467 0.3303 0.5886 0.1058 0.6329 0.0525 0.5021 0.8522 0.9850 0.8669 0.6468 0.7454 0.5859 0.9095 0 0.9205 0.9559 0.5630 0.5145 0.8511 0.5567 0.1483 0.8103 0.0022 0.5353 0.1770 0.2112 0.4281 0.1541 0.2924 0.8053 0.8297 0.8764 0.8907 0.7763 0.4648 0.5268 0.5473 0.8372 0.0021 0.3477 0.6290 0.4462 0.4127 0.6819 0.1931 0.1141 0.1004 0.4312 0.7446 0.6577 0.0293 0.9541 0.6805 0.7956 0.7856 0.9223 0.9339 0.7422 0.5386 0.8104 0.5504 0.5223 0.9928 0.7563 0.5973 0.7489 0.7517 0.3505 0.1783 0.0454 0.0018 0.1122 0.2794 0.9055 0.8711 0.5356 0.5082 0.5185 0.5091 0.1784 0.7537 0.6698 Column 10 0.7949 0.0515 0.7657 0.4215 0.2646 0.5573 0.1427 0.1656 0.2799 0.3161 A(:,:,2) = Columns 1 through 9 0.2722 0 0.7550 0.6290 0.1733 0.5941 0.9175 0.4514 0.5764 0.3917 0.0629 0.1479 0.0077 0.8604 0.7829 0.0630 0.8058 0.4609 0.8530 0.8458 0.1186 0.3826 0.9671 0.6746 0.1648 0.9115 0.9379 0.4052 0.2662 0.5707 0.6416 0.4358 0.6310 0.6444 0.8602 0.7353 0.9166 0.0667 0.7415 0.9118 0.1445 0.4228 0.9874 0.7821 0.4074 0.9503 0.4830 0.8128 0.5259 0.0275 0.3687 0.7107 0.7440 0.0514 0.6534 0.4445 0.5363 0.6542 0.6941 0.8296 0.0686 0.9525 0.8851 0.9356 0.0407 0.3936 0.1644 0.2250 0.6974 0.5735 0.4274 0.3478 0.0128 0.8937 0.2752 0.2304 0.9100 0.1735 0.4158 0.4160 0.8337 0.0466 0.2752 0.1660 0.9213 0.4712 0.5664 0.8705 0.9139 0.7084 Column 10 0.6878 0.5449 0.1348 0.7767 0.0083 0.6288 0.5095 0.0900 0.6677 0.3445 A(:,:,3) = Columns 1 through 9 0.5270 0.1283 0.4782 0.5593 0.9337 0.6673 0.2132 0.5958 0.9381 0.2393 0.5738 0.5621 0.4776 0.5842 0.9640 0.4208 0.6922 0.8374 0.3098 0.5357 0.4366 0.7549 0.6973 0.6512 0.1003 0.2682 0.2279 0.0927 0.4202 0.5032 0.0354 0.5653 0.7026 0.3138 0.7975 0.2456 0.5087 0.1226 0.0427 0.4220 0.5992 0 0.2492 0.1184 0.9065 0.1339 0.0788 0.8209 0.2873 0.2041 0.9637 0.5668 0.8504 0.6457 0.6468 0.4969 0.4142 0.3735 0.3473 0.0089 0.5561 0.6797 0.0694 0.0055 0.3229 0.6480 0.5613 0.3452 0.2902 0.9738 0.1523 0.7640 0.9004 0.3959 0.6534 0.0661 0.8573 0.8532 0.7268 0.1823 0.1097 0.8763 0.1302 0.9299 0.9471 0.6697 0.4185 0.4906 0.7048 0.3468 Column 10 0.8537 0.0256 0.7776 0.9503 0.0712 0.7476 0.7911 0.6050 0.6714 0.4126 A(:,:,4) = Columns 1 through 9 0.4606 0.6410 0.9542 0.9315 0.3380 0.3737 0.5221 0.5090 0.5363 0.6753 0.0378 0.3889 0.7778 0.1720 0.8714 0.3535 0.8278 0.4635 0.6256 0.4798 0.6496 0.4450 0.1895 0.1976 0.3650 0.6926 0.1821 0.4891 0.4896 0.3292 0.8369 0.1252 0.5046 0.2792 0.9815 0.7991 0.8127 0.4641 0.6495 0.1442 0.4840 0.4219 0.2885 0.3481 0.7207 0.4504 0.2544 0.4947 0.7016 0.3719 0.4172 0.5032 0.6033 0.6787 0.6318 0.2756 0.1868 0.2281 0.3757 0.5891 0.4918 0.2553 0.2424 0.4586 0.1574 0.3734 0.2181 0.5341 0.9290 0.0172 0.1064 0.1418 0.3172 0.8113 0.8236 0.0370 0.7076 0.7796 0.3308 0.6836 0.9721 0.3513 0.2613 0.6501 0.7619 0.1481 0.8676 0.0763 0.6002 0.2750 Column 10 0.5953 0.2750 0.5195 0.9570 0.2899 0.0101 0.7466 0.3887 0.6063 0.1620 A(:,:,5) = Columns 1 through 9 0.7536 0.6610 0.0187 0.0131 0.5882 0.3949 0.5664 0.4994 0.4265 0.5825 0.5175 0.4500 0.6539 0.3303 0.0487 0.9977 0.3053 0.0442 0.8886 0.3086 0.7458 0.8888 0.2228 0.7422 0.5007 0.1473 0.4333 0.8644 0.7863 0.6774 0.7644 0.6786 0.3790 0.4755 0.8988 0.8757 0.2899 0.6034 0.2752 0.1159 0.2862 0.3677 0.6922 0.5072 0.1396 0.1387 0.3567 0.6139 0.7823 0.2584 0.5037 0.5359 0.4667 0.5138 0.7535 0.4745 0.6858 0.7460 0.0334 0.0588 0.1590 0.5043 0.9874 0.1578 0.4575 0.8401 0.1304 0.0290 0.8400 0.7192 0.7711 0.7138 0.2169 0.5924 0.8645 0.1998 0.4240 0.6727 0.0712 0.6972 0.1829 0.4848 0.6600 0.4052 0.4042 0.0222 0.1186 0.0107 0.7389 0.7404 Column 10 0.7603 0.2049 0.1402 0.3634 0.0332 0.3977 0.0677 0.4485 0.9368 0.5635 A(:,:,6) = Columns 1 through 9 0.9157 0.5948 0.0798 0.7653 0.9518 0.3832 0.3323 0.6028 0.3301 0.8610 0.8802 0.1841 0.8611 0.2081 0.3741 0.3052 0.0627 0.3057 0.5568 0.7475 0.0254 0.6035 0.4701 0.0411 0.4506 0.4917 0.4576 0.2713 0.5875 0.9831 0.0020 0.3749 0.1847 0.8036 0.7025 0.0583 0.5668 0.2101 0.2536 0.3795 0.0060 0.4257 0.0091 0.1942 0.1859 0.0359 0.2712 0.8686 0.5853 0.1127 0.8606 0.9349 0.5290 0.8709 0.1491 0.4972 0.5586 0.4344 0.5554 0.2339 0.8559 0.0193 0.8713 0.3873 0.3217 0.4499 0.6501 0.4264 0.1730 0.9421 0.7499 0.4079 0.0026 0.0119 0.2362 0.4751 0.1291 0.9434 0.2762 0.2507 0.1330 0.2741 0.3046 0.5047 0.9398 0.6151 0.4528 0.8365 0.6466 0.3668 Column 10 0.9233 0.7205 0.0198 0.7743 0.9869 0.5732 0.0813 0.9165 0.2620 0.7108 A(:,:,7) = Columns 1 through 9 0.8084 0.8933 0.9876 0.0350 0.1650 0.8907 0.4148 0.1069 0.1078 0.0938 0.1208 0.7393 0.5260 0.3532 0.7981 0.7734 0.2096 0.9332 0.4967 0.4104 0.8271 0.6468 0.1971 0.4180 0.8438 0.5269 0.5387 0.6117 0.2781 0.8798 0.2406 0.0822 0.5546 0.8487 0.3460 0.8100 0.8547 0.9919 0.1083 0.1889 0.3360 0.3555 0.2900 0.7489 0.8078 0.1988 0.2675 0.2187 0.4499 0.6174 0.7083 0.5170 0.1270 0.9241 0.0007 0.3017 0.4445 0.5998 0.4581 0.4958 0.6301 0.7831 0.4967 0.7422 0.6779 0.6524 0.4541 0.0183 0.5260 0.0452 0.5869 0.2738 0.2576 0.6574 0.7589 0.7819 0.9157 0.6697 0.9089 0.4201 0.6718 0.8060 0.7019 0.2119 0.4843 0.4985 0.4229 0.0213 0.7307 0.9752 Column 10 0.9076 0.0066 0.6127 0.0995 0.3881 0.6101 0.8790 0.5646 0.9431 0.7310 A(:,:,8) = Columns 1 through 9 0.8843 0.0770 0.5113 0.6934 0.3598 0.7764 0.9682 0.9151 0.3234 0.7776 0.6603 0.1547 0.8236 0.1612 0.8918 0.2878 0.9580 0.6557 0.0653 0.8427 0.7286 0.1787 0.4838 0.0751 0.5089 0.9265 0.5430 0.5334 0.9069 0.6148 0.1391 0.1086 0.7546 0.1221 0.8571 0.1522 0.6508 0.4565 0.0444 0.0620 0.9804 0.7489 0.8012 0.6902 0.5038 0.7941 0.7088 0.4535 0.3509 0.9542 0.5721 0.5885 0.2380 0.8383 0.7804 0.0645 0.4922 0.0162 0.4405 0.6772 0.4095 0.3308 0.8895 0.2450 0.0158 0.7702 0.7671 0.4258 0.2359 0.8521 0.6920 0.3745 0.2824 0.0180 0.0941 0.8874 0.4809 0.6131 0.8751 0.9554 0.8406 0.4550 0.9018 0.8169 0.6494 0.1853 0.2123 0.0937 0.2509 0.4225 Column 10 0.0064 0.7160 0.6875 0.6711 0.6953 0.2613 0.2372 0.0740 0.0823 0.7553 A(:,:,9) = Columns 1 through 9 0.5299 0.8758 0.6435 0.7260 0.0987 0.2012 0.7988 0.1311 0.9483 0.1248 0.0774 0.7224 0.2499 0.9965 0.6833 0.1961 0.0738 0.4555 0.6172 0.7508 0.9757 0.0209 0.8510 0.7111 0.6259 0.5870 0.3021 0.1920 0.9420 0.4753 0.2966 0.0494 0.8060 0.6576 0.2966 0.5569 0.4694 0.8993 0.6087 0.9200 0.9273 0.2811 0.3016 0.6294 0.9608 0.5161 0.4786 0.4460 0.0257 0.7440 0.4199 0.9750 0.6650 0.4160 0.4249 0.2635 0.2092 0.4708 0.7320 0.8275 0.9912 0.4884 0.7514 0.5450 0.2323 0.6916 0.1157 0.2227 0.4258 0.5084 0.4118 0.2660 0.5894 0.7646 0.4880 0.5329 0.0829 0.7584 0.7726 0.5226 0.6231 0.5795 0.5547 0.2691 0.8320 0.3500 0.1487 0.3276 0.2660 0.5701 Column 10 0.8796 0.0981 0.9998 0.8407 0.3906 0.1822 0.9900 0.9690 0.7756 0.6057 A(:,:,10) = Columns 1 through 9 0.5849 0.3283 0.1615 0.1074 0.3825 0.2482 0.8780 0.0707 0.8650 0.1636 0.3291 0.4282 0.4724 0.7011 0.9901 0.8809 0.9093 0.5355 0.6628 0.6470 0.4756 0.0884 0.5949 0.1280 0.5149 0.7021 0.0456 0.2649 0.3741 0.9820 0.6908 0.7178 0.0671 0.3365 0.7460 0.1906 0.1641 0....

6   Pass
%% test 6 repmat ! 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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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Column 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

7   Pass
%% test 7 magic! 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

8   Pass
%% test 8 floating (maybe people will work with string recognition) A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

A = 13.3000