Cody

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

Solution 1625614

Submitted on 12 Sep 2018 by Victor Gonzalez
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

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

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

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

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.4795 0.6562 0.9477 0.1825 0.6624 0.4052 0.5227 0.6684 0.1555 0.8861 0.7588 0.9801 0.5393 0.4976 0.9032 0.1261 0.1941 0.1050 0.8596 0.9928 0.6152 0.8279 0.4110 0 0.3394 0.1961 0.3179 0.8396 0.4140 0.8703 0.4830 0.5084 0.7203 0.2742 0.8365 0.7107 0.0629 0.9353 0.1462 0.0109 0.7255 0.3054 0.5268 0.5384 0.0702 0.7307 0.5446 0.5072 0.8432 0.8460 0.6155 0.5092 0.5700 0.5308 0.9764 0.1975 0.5760 0.9820 0.5234 0.7918 0.5399 0.4203 0.2005 0.7647 0.8054 0.1656 0.3608 0.7701 0.5692 0.2729 0.4302 0.2264 0.0086 0.5698 0.2313 0.7667 0.8507 0.0946 0.0431 0.9566 0.7239 0.4215 0.9993 0.4153 0.4899 0.7271 0.4952 0.8792 0.9429 0.1745 0.1890 0.7608 0.6737 0.4761 0.8629 0.2234 0.2172 0.7286 0.1939 0.4944 A(:,:,2) = 0.3584 0 0.6819 0.0176 0.6366 0.7898 0.4928 0.1415 0.1876 0.3850 0.7152 0.8701 0.2886 0.0813 0.5949 0.1693 0.5762 0.3350 0.3911 0.6819 0.9507 0.2970 0.6776 0.1539 0.0094 0.9602 0.2937 0.6026 0.9165 0.0149 0.8079 0.1262 0.7228 0.0636 0.9010 0.7930 0.7096 0.7238 0.9746 0.1397 0.1887 0.4603 0.2723 0.2433 0.9693 0.4053 0.9447 0.5847 0.7480 0.5417 0.2168 0.6572 0.2162 0.6730 0.8093 0.4293 0.6690 0.6193 0.6186 0.7199 0.1296 0.7765 0.3390 0.6797 0.1464 0.8239 0.2585 0.8664 0.8516 0.0021 0.3279 0.0538 0.1981 0.7634 0.1513 0.6293 0.3626 0.8697 0.9540 0.7593 0.1454 0.3119 0.1839 0.0403 0.7704 0.5784 0.5465 0.9104 0.7238 0.3962 0.7804 0.8206 0.4030 0.7119 0.7694 0.3322 0.0154 0.3172 0.4672 0.7269 A(:,:,3) = 0.2504 0.8872 0.7043 0.5217 0.2856 0.4930 0.0387 0.8624 0.8010 0.5527 0.9616 0.8396 0.4605 0.7709 0.3831 0.1514 0.5469 0.0272 0.9554 0.2857 0.0641 0.2604 0.4506 0.7091 0.9804 0.1563 0.4512 0.9145 0.4044 0.1674 0.2664 0.9376 0.7056 0.6726 0.2129 0.3983 0.8275 0.6622 0.9021 0.7012 0.2346 0.0930 0.5799 0.9523 0.7671 0 0.3420 0.9737 0.8932 0.2586 0.6823 0.9953 0.4948 0.2830 0.9734 0.5708 0.5631 0.6237 0.0270 0.2812 0.6429 0.2527 0.6862 0.5035 0.8559 0.9498 0.3965 0.1688 0.0729 0.5684 0.0461 0.1479 0.4198 0.7252 0.7497 0.4542 0.6213 0.9428 0.0717 0.5611 0.1369 0.1326 0.6611 0.8767 0.9681 0.4663 0.4409 0.5114 0.6320 0.2899 0.8383 0.3151 0.6699 0.4934 0.5466 0.8317 0.2182 0.1764 0.9866 0.4784 A(:,:,4) = 0.4844 0.0870 0.7699 0.3982 0.9300 0.1775 0.6427 0.5427 0.5276 0.8879 0.3733 0.8882 0.5153 0.5355 0.3038 0.4771 0.7482 0.3204 0.6229 0.0910 0.9284 0.6837 0.9527 0.4768 0.4134 0.3149 0.7855 0.8376 0.3309 0.5906 0.0886 0.4455 0.3459 0.2047 0.5924 0.7909 0.5497 0.7667 0.3914 0.6978 0.4789 0.0667 0.0630 0.9731 0.2771 0.2517 0.6645 0.8710 0.1994 0.2336 0.2944 0.3035 0.7750 0.4457 0.6372 0.3215 0.2759 0.5002 0.3739 0.5949 0.4285 0.2683 0.9453 0.1171 0.2570 0.4786 0.0972 0.4110 0.3550 0.4967 0.2386 0.8720 0.7795 0.6442 0.0680 0.6435 0.2244 0.4986 0.5499 0.0711 0.4259 0.4738 0.8322 0.1160 0.9740 0.5663 0.5451 0.1241 0.3425 0.1775 0.5236 0.7711 0.3745 0.3903 0.9071 0.8511 0.5607 0.9715 0.7725 0.8265 A(:,:,5) = 0.7565 0.2039 0.0472 0.3926 0.0944 0.5202 0.9385 0.2285 0.8159 0.6246 0.6385 0.1932 0.6091 0.7797 0.4489 0.3618 0.4800 0.5281 0.7466 0.7055 0.1581 0.3072 0.9627 0.3883 0.5550 0.0181 0.8615 0.8261 0.3997 0.3298 0.9617 0.5216 0.8229 0.4164 0.2170 0.6148 0.5134 0.5583 0.3506 0.7310 0.9768 0.2868 0.0262 0.6124 0.2061 0.1296 0.8346 0.1549 0.5763 0.2780 0.2605 0.1350 0.4030 0.5789 0.6504 0.5943 0.1181 0.4889 0.0050 0.2766 0.5921 0.4460 0.9417 0.9613 0.9525 0.1474 0.1564 0.2169 0.5677 0.7104 0.1962 0.9997 0.1469 0.4745 0.6674 0.1270 0.1117 0.1680 0.4422 0.8922 0.1175 0.9971 0.6558 0.6024 0.2936 0.9166 0.8725 0.5914 0.2526 0.3341 0.4337 0.2784 0.2012 0.5904 0.8988 0.3995 0.0069 0.7648 0.5682 0.6596 A(:,:,6) = 0.8266 0.3041 0.9618 0.6198 0.5308 0.8303 0.2576 0.3807 0.0346 0.6064 0.2519 0.6612 0.1166 0.9150 0.0936 0.7900 0.0973 0.9572 0.0498 0.7302 0.5931 0.0311 0.5583 0.7521 0.9410 0.9642 0.5984 0.7340 0.1055 0.6652 0.0726 0.0119 0.8429 0.3290 0.6459 0.3440 0.3927 0.4390 0.9575 0.1297 0.2009 0.5435 0.5469 0.3817 0.0549 0.6336 0.3799 0.7618 0.6820 0.5285 0.8135 0.3666 0.1108 0.2579 0.2458 0.4287 0.4614 0.8808 0.6640 0.6538 0.5166 0.5872 0.4833 0.6346 0.5672 0.4455 0.1662 0.5107 0.8969 0.9715 0.0490 0.9626 0.3433 0.0655 0.1217 0.4477 0.9939 0.7295 0.4482 0.2200 0.2037 0.7994 0.0679 0.5751 0.8489 0.5726 0.1184 0.4159 0.9498 0.4801 0.7881 0.1821 0.8688 0.2017 0.4958 0.6225 0.1402 0.6412 0.3630 0.1553 A(:,:,7) = 0.8530 0.9183 0.6820 0.6397 0.6042 0.5410 0.7377 0.9575 0.3295 0.2444 0.1471 0.4859 0.7883 0.8430 0.9369 0.6825 0.6684 0.5138 0.4133 0.2369 0.4115 0.1705 0.3650 0.6718 0.9127 0.9269 0.7749 0.1707 0.1950 0.5873 0.7011 0.0523 0.6785 0.9055 0.5708 0.9979 0.6640 0.4350 0.8793 0.1960 0.2165 0.4374 0.3334 0.5482 0.0043 0.7151 0.3575 0.3570 0.3167 0.8534 0.1068 0.1028 0.4499 0.8252 0.3946 0.3271 0.7043 0.3269 0.2650 0.8815 0.9144 0.5380 0.0384 0.0150 0.8478 0.6885 0.7397 0.6965 0.0551 0.2945 0.9237 0.1930 0.6337 0.6194 0.8445 0.9056 0.0229 0.2542 0.0342 0.3137 0.2322 0.8283 0.7930 0.3432 0.4510 0.6449 0.9766 0.6296 0.2255 0.6677 0.8475 0.1026 0.1245 0.5336 0.5054 0.8312 0.8103 0.8382 0.4240 0.2016 A(:,:,8) = 0.3034 0.0042 0.0496 0.0537 0.1491 0.1381 0.5819 0.6267 0.5268 0.4552 0.7432 0.8594 0.1140 0.7463 0.4238 0.4946 0.1411 0.2698 0.0102 0.4102 0.8704 0.2088 0.2001 0.6584 0.3626 0.4675 0.3546 0.0194 0.7304 0.0349 0.1274 0.8554 0.2142 0.9624 0.0021 0.2736 0.6834 0.9786 0.9238 0.3447 0.1331 0.9463 0.0928 0.2708 0.2736 0.7833 0.0275 0.7307 0.6468 0.5097 0.8412 0.6383 0.0286 0.7516 0.5215 0.4195 0.5013 0.9573 0.2339 0.8465 0.1696 0.7354 0.0787 0.7483 0.0997 0.9985 0.6794 0.5111 0.4776 0.2005 0.1305 0.6903 0.0024 0.2837 0.1017 0.4970 0.0640 0.9462 0.5172 0.9807 0.5353 0.4447 0.7716 0.0201 0.7246 0.2364 0.5397 0.8779 0.1816 0.2983 0.4322 0.7212 0.6506 0.3003 0.0514 0.3742 0.9061 0.1866 0.0451 0.1709 A(:,:,9) = 0.8864 0.2658 0.7868 0.4132 0.2915 0.8444 0.5818 0.6157 0.8043 0.5192 0.1557 0.0358 0.3580 0.6484 0.0578 0.5974 0.1163 0.3515 0.7509 0.9296 0.9643 0.7665 0.6158 0.4276 0.9442 0.6872 0.9388 0.1741 0.4905 0.7078 0.2730 0.3815 0.5527 0.1385 0.6075 0.1084 0.5795 0.8215 0.6900 0.4170 0.0273 0.4499 0.6013 0.3485 0.5628 0.0593 0.6324 0.6021 0.0596 0.8620 0.3358 0.0880 0.1685 0.8161 0.4722 0.5482 0.0384 0.3796 0.7957 0.5758 0.9442 0.6091 0.0011 0.5902 0.6383 0.9797 0.8027 0.3818 0.2200 0.8837 0.7185 0.2898 0.9609 0.5919 0.1319 0.0092 0.2418 0.4606 0.4494 0.4736 0.8076 0.8679 0.8047 0.8490 0.9049 0.3718 0.3891 0.2259 0.8130 0.3835 0.0784 0.1384 0.9437 0.7534 0.2409 0.6875 0.6380 0.1200 0.5828 0.7011 A(:,:,10) = 0.7093 0.6071 0.1989 0.4035 0.8166 0.8929 0.3957 0.4573 0.4673 0.0367 0.0058 0.1810 0.6858 0.9054 0.1960 0.2602 0.8096 0.2414 0.7447 0.9812 0.8905 0.0316 0.6552 0.3501 0.1688 0.5936 0.0849 0.6552 0.1618 0.6511 0.3233 0.2506 0.8061 0.3057 0.9013 0.3997 0.9725 0.2129 0.8021 0.4530 0.8642 0.9029 0.4645 0.6613 0.9607 0.4809 0.4908 0.8331 0.1768 0.7984 0.8446 0.0470 0.2997 0.6855 0.5370 0.9898 0.2433 0.7813 0.6183 0.7271 0.7018 0.6524 0.9924 0.5181 0.0055 0.0730 0.3688 0.9702 0.4550 0.5898 0.8952 0.9440 0.4286 0.5969 0.7696 0.4873 ...

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

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

8   Pass
A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

A = 13.3000