Cody

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

Solution 1218405

Submitted on 22 Jun 2017 by Augusto Mazzei
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) = 0.2759 0.5873 0.7584 0.9061 0.2527 0.7691 0.3198 0.5380 0.5004 0.7497 0.4564 0.6480 0.9593 0.3862 0.0240 0.5217 0.2356 0.3685 0.2079 0.9280 0.9927 0.4671 0.0523 0 0.5347 0.1610 0.0326 0.5141 0.7598 0.6811 0.7282 0.3416 0.3051 0.7271 0.2760 0.3170 0.2752 0.3447 0.1986 0.3243 0.1352 0.1054 0.2106 0.8655 0.4559 0.3978 0.8026 0.8895 0.8889 0.7766 0.3968 0.8004 0.4481 0.2919 0.7959 0.5897 0.3752 0.8160 0.9726 0.3877 0.9416 0.1594 0.9524 0.7012 0.8824 0.9633 0.1797 0.1564 0.3316 0.6379 0.0118 0.7939 0.0921 0.3243 0.8484 0.2523 0.3145 0.7513 0.8946 0.2373 0.2981 0.8720 0.8651 0.2804 0.7403 0.2854 0.2129 0.4921 0.9962 0.8556 0.9405 0.5548 0.7274 0.5591 0.2751 0.9190 0.0260 0.1046 0.2079 0.7854 B(:,:,2) = 0.3223 0 0.6035 0.3189 0.9080 0.0159 0.9858 0.5235 0.9452 0.7094 0.5739 0.6301 0.1030 0.4722 0.0121 0.7638 0.1542 0.4917 0.6560 0.5223 0.8174 0.8606 0.1881 0.6308 0.2569 0.0105 0.8163 0.0518 0.8944 0.1592 0.6597 0.9570 0.1286 0.4921 0.6442 0.4260 0.1217 0.0310 0.6373 0.7079 0.0338 0.5152 0.1190 0.9283 0.1722 0.9265 0.8414 0.7585 0.0890 0.2164 0.1233 0.8431 0.5079 0.2323 0.5598 0.8237 0.0536 0.2176 0.7035 0.7639 0.6695 0.0107 0.9271 0.7236 0.6657 0.8073 0.8280 0.0746 0.1021 0.8144 0.1632 0.6713 0.4707 0.1352 0.5769 0.9674 0.4063 0.1922 0.0730 0.0707 0.7704 0.2509 0.6671 0.4370 0.2525 0.8589 0.3361 0.5967 0.0137 0.6726 0.7665 0.2935 0.2007 0.7250 0.5958 0.3394 0.2134 0.4264 0.1011 0.1042 B(:,:,3) = 0.4964 0.0841 0.7694 0.7641 0.1562 0.4511 0.6950 0.9845 0.1182 0.8403 0.0875 0.7127 0.0427 0.1606 0.8535 0.7185 0.9367 0.2128 0.5478 0.7675 0.8199 0.8720 0.9674 0.9075 0.5210 0.3103 0.0577 0.3089 0.2199 0.8776 0.6360 0.5782 0.4953 0.3917 0.5340 0.0498 0.0274 0.4297 0.8078 0.9821 0.1312 0.5677 0.3062 0.2669 0.9944 0 0.1341 0.4893 0.4480 0.0967 0.2157 0.1429 0.2606 0.2035 0.8511 0.7876 0.7562 0.4194 0.6515 0.6796 0.9329 0.5624 0.7556 0.9112 0.8441 0.2083 0.4199 0.4253 0.2902 0.1771 0.9637 0.9077 0.0208 0.2407 0.8555 0.3635 0.3917 0.9493 0.2121 0.9132 0.6418 0.5614 0.1070 0.0320 0.6131 0.1078 0.6676 0.8593 0.1207 0.2468 0.4541 0.5201 0.4923 0.3088 0.2028 0.8213 0.7845 0.5099 0.8753 0.8007 B(:,:,4) = 0.8127 0.7788 0.8559 0.5410 0.4257 0.1656 0.6281 0.0634 0.0106 0.8883 0.9075 0.6759 0.8659 0.2206 0.0436 0.7523 0.5289 0.2544 0.2908 0.8072 0.9869 0.2809 0.0293 0.6557 0.7082 0.2909 0.4566 0.7226 0.3677 0.4140 0.0216 0.3661 0.2811 0.6487 0.9493 0.7776 0.1477 0.0796 0.9846 0.9631 0.2290 0.2516 0.7936 0.1689 0.9106 0.1888 0.1091 0.1553 0.1186 0.1891 0.5847 0.1681 0.7653 0.6213 0.3922 0.1387 0.8706 0.7564 0.4351 0.1426 0.3497 0.8151 0.3441 0.0220 0.9038 0.3868 0.4427 0.5919 0.5672 0.7083 0.4483 0.9110 0.0841 0.9816 0.1626 0.1177 0.2506 0.4465 0.6483 0.4089 0.8910 0.4096 0.1970 0.0647 0.3810 0.9151 0.4609 0.6922 0.5351 0.6386 0.9712 0.9393 0.4098 0.4023 0.8698 0.6980 0.1433 0.8124 0.0993 0.6010 B(:,:,5) = 0.2527 0.2554 0.4154 0.5789 0.6636 0.2365 0.9212 0.2447 0.8494 0.0044 0.2776 0.9646 0.1385 0.8598 0.4525 0.3058 0.2836 0.6092 0.2407 0.3155 0.4422 0.5188 0.6021 0.3582 0.0641 0.0449 0.1482 0.8264 0.8589 0.2841 0.1529 0.3364 0.1212 0.6644 0.0101 0.9769 0.6492 0.8580 0.7563 0.6220 0.6367 0.5954 0.2215 0.2017 0.3442 0.3927 0.4921 0.6028 0.7573 0.0893 0.9984 0.5046 0.8613 0.5319 0.5243 0.1178 0.5107 0.3113 0.6877 0.9636 0.1863 0.7621 0.4337 0.1827 0.4436 0.4892 0.0206 0.7483 0.3167 0.6723 0.5798 0.2999 0.4075 0.7037 0.0630 0.3817 0.6263 0.1302 0.3711 0.5297 0.4318 0.8013 0.0784 0.0001 0.8749 0.3480 0.1077 0.3050 0.3823 0.0683 0.7137 0.3953 0.7474 0.6257 0.0150 0.8187 0.7484 0.5299 0.5538 0.5356 B(:,:,6) = 0.1267 0.1045 0.8975 0.0858 0.6595 0.7920 0.8894 0.4865 0.1306 0.7353 0.2278 0.5015 0.9504 0.0646 0.7990 0.7209 0.4785 0.0492 0.1364 0.5560 0.8709 0.5678 0.4712 0.5700 0.2334 0.0020 0.7516 0.3305 0.7593 0.0766 0.5905 0.1551 0.1607 0.7895 0.6733 0.5820 0.0608 0.8474 0.2932 0.1014 0.9462 0.4223 0.6772 0.5931 0.1074 0.4057 0.5661 0.5120 0.6489 0.9536 0.3318 0.2648 0.5691 0.9503 0.7647 0.6472 0.8121 0.7470 0.3727 0.4040 0.1896 0.8699 0.2299 0.5873 0.7564 0.3040 0.1402 0.8133 0.7630 0.5936 0.0346 0.3681 0.3171 0.5276 0.9680 0.8997 0.4553 0.1998 0.1663 0.9906 0.5029 0.9668 0.0847 0.2442 0.3334 0.7116 0.2851 0.8271 0.8648 0.2221 0.7407 0.2589 0.1806 0.4280 0.7631 0.1641 0.8058 0.9887 0.8570 0.4345 B(:,:,7) = 0.4890 0.1196 0.9105 0.6930 0.4694 0.0273 0.1529 0.0721 0.8795 0.6797 0.6029 0.7261 0.9800 0.8982 0.7537 0.3573 0.1437 0.1896 0.1811 0.5819 0.6437 0.4072 0.0608 0.2842 0.8513 0.7753 0.2797 0.0958 0.5674 0.2187 0.5712 0.5364 0.9132 0.9769 0.0602 0.1910 0.4811 0.9520 0.5546 0.7570 0.9345 0.2424 0.8951 0.7200 0.4223 0.2951 0.2620 0.6631 0.4024 0.8403 0.0582 0.4197 0.4778 0.1348 0.9805 0.9594 0.1950 0.8291 0.3405 0.3632 0.5486 0.8448 0.5943 0.1676 0.4888 0.8736 0.4580 0.1837 0.7187 0.4077 0.5032 0.8200 0.0867 0.2307 0.3078 0.0047 0.3869 0.3613 0.0986 0.2405 0.5323 0.2753 0.9880 0.7663 0.2260 0.8647 0.4787 0.4766 0.6760 0.9334 0.8833 0.9854 0.9610 0.4223 0.6024 0.4763 0.4318 0.6481 0.3121 0.4315 B(:,:,8) = 0.7819 0.0035 0.5339 0.4426 0.6757 0.1005 0.9165 0.5759 0.7067 0.7205 0.4794 0.5375 0.6504 0.3154 0.4148 0.2433 0.1316 0.4119 0.3343 0.4857 0.7801 0.5369 0.9365 0.3662 0.1634 0.1112 0.7403 0.6875 0.7739 0.9014 0.9207 0.8573 0.2066 0.1010 0.6077 0.3715 0.3854 0.5956 0.3058 0.2603 0.7865 0.0630 0.1837 0.7172 0.9301 0.2311 0.6768 0.5671 0.7770 0.9462 0.7479 0.0574 0.6748 0.0008 0.9630 0.5406 0.3648 0.8774 0.8637 0.1850 0.2232 0.7026 0.7542 0.5603 0.8412 0.7437 0.4733 0.0981 0.9671 0.8978 0.7783 0.4744 0.6032 0.4436 0.2892 0.4326 0.9338 0.1328 0.1959 0.9132 0.2045 0.5939 0.2523 0.0755 0.8849 0.4781 0.1232 0.3034 0.6190 0.0437 0.8659 0.5338 0.5425 0.6567 0.6946 0.6966 0.3362 0.0289 0.3081 0.2046 B(:,:,9) = 0.6454 0.2461 0.2751 0.3220 0.4875 0.7733 0.2083 0.5287 0.6839 0.8923 0.2724 0.0427 0.2401 0.4623 0.9766 0.7735 0.3131 0.5896 0.2704 0.1661 0.2176 0.0735 0.1301 0.3132 0.7865 0.9132 0.8814 0.9580 0.0171 0.2615 0.2068 0.6516 0.4808 0.7413 0.0494 0.7651 0.9184 0.9654 0.8819 0.8247 0.1604 0.6918 0.5464 0.9708 0.5060 0.0670 0.2090 0.7250 0.7303 0.1946 0.9145 0.6540 0.5733 0.2365 0.6841 0.9360 0.2578 0.0132 0.3834 0.4889 0.1434 0.1549 0.0544 0.9163 0.0029 0.3417 0.3238 0.5723 0.9128 0.7416 0.9646 0.3116 0.6845 0.9344 0.6348 0.1633 0.8347 0.9724 0.3467 0.9267 0.8867 0.3075 0.4288 0.7103 0.3865 0.9153 0.5898 0.3592 0.7785 0.8426 0.8927 0.7877 0.9136 0.4740 0.5614 0.3711 0.6240 0.8588 0.0491 0.0502 B(:,:,10) = 0.4321 0.7281 0.8198 0.2001 0.2118 0.6394 0.3250 0.7263 0.5632 0.6495 0.0273 0.6306 0.8772 0.7722 0.8434 0.1451 0.5869 0.5372 0.1490 0.5905 0.7355 0.5682 0.5970 0.0091 0.5441 0.9291 0.1624 0.9392 0.9001 0.6446 0.8594 0.9826 0.2134 0.1903 0.2907 0.8452 0.8152 0.7683 0.0496 0.5027 0.3645 0.8568 0.1719 0.2284 0.5879 0.9523 0.3894 0.7571 0.6344 0.4433 0.6480 0.9906 0.3438 0.4821 0.0562 0.2405 0.5974 0.1595 0.6802 0.0671 0.4359 0.0651 0.0852 0.1763 0.4117 0.2722 0.5414 0.8344 0.3528 0.0049 0.1507 0.6292 0.8390 0.6412 0.9958 0.0379 ...

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