Cody

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

Solution 2032615

Submitted on 23 Nov 2019 by Jakub Suchý
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.0439 0.5451 0.6116 0.3599 0.5498 0.0866 0.5598 0.4724 0.4842 0.1499 0.0581 0.3684 0.9135 0.8637 0.6344 0.0852 0.8188 0.9386 0.8575 0.1084 0.2953 0.0910 0.4914 0 0.3049 0.1423 0.4666 0.2345 0.6479 0.3839 0.2560 0.0318 0.4953 0.6105 0.7435 0.8456 0.0197 0.5070 0.9442 0.5111 0.9843 0.6080 0.9943 0.4638 0.8651 0.9908 0.5136 0.1653 0.3397 0.7584 0.4083 0.5170 0.3359 0.1710 0.2676 0.8700 0.8905 0.2553 0.9706 0.3869 0.7559 0.7634 0.0974 0.6400 0.5391 0.7159 0.1904 0.4204 0.0151 0.8149 0.2028 0.3703 0.7508 0.9345 0.4703 0.3477 0.1425 0.4501 0.9870 0.3284 0.1375 0.6169 0.0244 0.3288 0.8984 0.4680 0.8956 0.9479 0.7965 0.3987 0.6200 0.5871 0.6496 0.3878 0.3585 0.2902 0.1125 0.0544 0.2641 0.5213 B(:,:,2) = 0.7632 0 0.2586 0.2626 0.1254 0.7243 0.0342 0.9924 0.4738 0.9116 0.8244 0.7638 0.4496 0.7921 0.3478 0.8533 0.3338 0.2258 0.7999 0.4988 0.5511 0.3331 0.6596 0.7602 0.5730 0.2372 0.9384 0.7253 0.0654 0.4580 0.3147 0.7114 0.3136 0.1443 0.5899 0.7058 0.2570 0.0999 0.0484 0.0018 0.0872 0.7137 0.7619 0.0135 0.7821 0.3587 0.7308 0.6971 0.1746 0.1656 0.5222 0.6292 0.4967 0.6199 0.8726 0.2048 0.6198 0.9459 0.3201 0.8300 0.3920 0.4703 0.4538 0.7909 0.7093 0.5389 0.5149 0.4682 0.5177 0.0413 0.5868 0.2297 0.7853 0.8167 0.8834 0.9012 0.0746 0.1699 0.6650 0.0041 0.9682 0.0051 0.0514 0.7600 0.3783 0.6812 0.1469 0.7714 0.7977 0.1587 0.1686 0.8433 0.2696 0.2674 0.7232 0.3599 0.5805 0.3558 0.4080 0.8557 B(:,:,3) = 0.5268 0.4435 0.5202 0.4847 0.7953 0.1774 0.9816 0.9814 0.6852 0.7358 0.3545 0.9230 0.0379 0.5392 0.7965 0.1899 0.7104 0.8523 0.8892 0.7726 0.5432 0.0558 0.9621 0.8494 0.3718 0.5139 0.3867 0.8533 0.7652 0.6326 0.4021 0.3750 0.7784 0.8312 0.6795 0.0056 0.5503 0.5778 0.5555 0.4582 0.2723 0.8111 0.4604 0.1305 0.1511 0 0.3836 0.4445 0.7068 0.3688 0.4048 0.5810 0.0894 0.6699 0.5099 0.5136 0.2821 0.3576 0.2483 0.4959 0.1050 0.4306 0.3371 0.1771 0.6798 0.0059 0.1268 0.6690 0.2080 0.5057 0.8132 0.0305 0.6264 0.6931 0.6229 0.4289 0.0805 0.7400 0.9731 0.1251 0.3608 0.0616 0.2998 0.1645 0.3688 0.2908 0.3073 0.9706 0.4133 0.8004 0.9580 0.5607 0.3153 0.7127 0.3557 0.3196 0.7559 0.5132 0.7215 0.8934 B(:,:,4) = 0.7767 0.8581 0.2084 0.0025 0.2453 0.0790 0.9648 0.8407 0.8066 0.6167 0.4501 0.5687 0.9841 0.0836 0.5454 0.1859 0.6344 0.7892 0.8286 0.5848 0.0359 0.9150 0.5060 0.3743 0.3703 0.1058 0.8026 0.8783 0.9912 0.5277 0.9186 0.0158 0.7154 0.8120 0.0773 0.3481 0.6200 0.5123 0.4631 0.7030 0.0317 0.0289 0.6611 0.0385 0.7563 0.3119 0.3134 0.7260 0.3691 0.4725 0.4815 0.5433 0.6194 0.0407 0.2272 0.2543 0.0196 0.6023 0.9706 0.8031 0.8593 0.1546 0.8000 0.4450 0.7190 0.4409 0.9569 0.0257 0.0048 0.5593 0.1594 0.6398 0.8032 0.2678 0.6391 0.4054 0.0034 0.9989 0.0742 0.2248 0.0449 0.0397 0.4630 0.6447 0.9553 0.1988 0.5829 0.6873 0.9676 0.7317 0.2509 0.3136 0.1465 0.3624 0.7743 0.0847 0.1630 0.0727 0.3231 0.2155 B(:,:,5) = 0.5878 0.0129 0.1548 0.0166 0.2928 0.1211 0.8665 0.1528 0.7195 0.0957 0.0247 0.3055 0.2435 0.4368 0.3868 0.5336 0.7586 0.4445 0.2184 0.9231 0.6350 0.1256 0.9740 0.1056 0.8899 0.7882 0.0950 0.6987 0.8441 0.0626 0.5488 0.9598 0.1897 0.1109 0.9213 0.3610 0.7125 0.3006 0.4353 0.7913 0.6028 0.0522 0.4292 0.0750 0.2492 0.9930 0.4425 0.9412 0.2272 0.6209 0.3635 0.5196 0.1187 0.8232 0.3434 0.1872 0.7644 0.1961 0.9913 0.4099 0.2982 0.9972 0.1781 0.6007 0.4430 0.7991 0.9343 0.9202 0.5066 0.8523 0.4475 0.3212 0.9851 0.0987 0.2859 0.3332 0.8649 0.7909 0.7838 0.4699 0.7983 0.8872 0.7782 0.2358 0.1343 0.0528 0.8547 0.6656 0.7378 0.5702 0.9836 0.5022 0.6051 0.1734 0.0451 0.7672 0.1211 0.0441 0.3915 0.5201 B(:,:,6) = 0.9663 0.6702 0.5935 0.3270 0.3108 0.1598 0.5274 0.3571 0.3688 0.3081 0.0969 0.8440 0.1596 0.6103 0.7302 0.6613 0.1039 0.4179 0.3864 0.2975 0.3469 0.5091 0.1314 0.1394 0.9568 0.3798 0.2787 0.6567 0.7799 0.9480 0.2210 0.7882 0.8629 0.5145 0.7702 0.2427 0.9602 0.6708 0.6146 0.6035 0.2164 0.4227 0.9498 0.2533 0.0591 0.7346 0.1400 0.2881 0.4152 0.9448 0.3762 0.4181 0.8112 0.4626 0.2786 0.9541 0.5146 0.8863 0.8881 0.5423 0.2743 0.5451 0.0584 0.3743 0.9429 0.5439 0.7055 0.9807 0.8253 0.8815 0.4398 0.6592 0.2103 0.2839 0.7030 0.5467 0.9190 0.3588 0.1902 0.1160 0.7273 0.7691 0.1964 0.0557 0.9011 0.3486 0.0587 0.8095 0.5994 0.2056 0.1328 0.5844 0.0442 0.2583 0.2511 0.5674 0.5730 0.5482 0.9959 0.3584 B(:,:,7) = 0.0577 0.7670 0.2860 0.1667 0.8201 0.5445 0.4314 0.9313 0.6972 0.0310 0.0567 0.7672 0.0996 0.1641 0.2307 0.4450 0.8787 0.0861 0.2203 0.7612 0.3683 0.3268 0.3229 0.1386 0.2278 0.5138 0.0787 0.1252 0.4865 0.8784 0.8935 0.2362 0.0455 0.9739 0.7930 0.5231 0.0648 0.5758 0.5207 0.6510 0.9560 0.0782 0.2350 0.2542 0.6048 0.8896 0.5434 0.8909 0.4386 0.7927 0.9274 0.2548 0.3516 0.4281 0.8774 0.7286 0.4339 0.9549 0.4926 0.3478 0.0577 0.1304 0.7585 0.1831 0.0500 0.9790 0.4959 0.1628 0.3131 0.9939 0.3369 0.2019 0.8460 0.0609 0.9073 0.6178 0.3821 0.5925 0.0083 0.2226 0.3843 0.2955 0.4508 0.5497 0.9179 0.2643 0.3418 0.1393 0.4081 0.2372 0.4857 0.2353 0.9571 0.4106 0.5905 0.6741 0.9805 0.1102 0.6129 0.2643 B(:,:,8) = 0.7297 0.6474 0.1150 0.9232 0.2440 0.7936 0.7095 0.0446 0.1997 0.6662 0.5666 0.6908 0.2590 0.8691 0.2647 0.7444 0.7601 0.1872 0.4483 0.8630 0.0338 0.0500 0.2916 0.5927 0.4166 0.5869 0.1792 0.1437 0.0615 0.1302 0.7505 0.4200 0.5138 0.4488 0.5421 0.1387 0.0975 0.4497 0.0477 0.8456 0.1722 0.9539 0.8222 0.4733 0.6029 0.2558 0.3231 0.8028 0.1615 0.8076 0.2861 0.1303 0.9559 0.4565 0.9297 0.1116 0.2842 0.7130 0.4372 0.3429 0.7613 0.3191 0.5690 0.0635 0.0770 0.0021 0.5019 0.0607 0.7725 0.7368 0.6270 0.4005 0.1987 0.6572 0.6693 0.9292 0.9977 0.2166 0.2178 0.1275 0.8836 0.3216 0.9191 0.7684 0.0984 0.0414 0.5646 0.6796 0.3475 0.4068 0.4231 0.7239 0.5181 0.3893 0.4442 0.8499 0.4074 0.8173 0.3407 0.9894 B(:,:,9) = 0.9268 0.5820 0.6453 0.9815 0.3904 0.0569 0.9880 0.4211 0.0597 0.7061 0.9226 0.0498 0.2494 0.5633 0.4731 0.8246 0.0970 0.0758 0.5057 0.7933 0.1815 0.5895 0.8961 0.2007 0.2403 0.4656 0.7660 0.3487 0.6391 0.9954 0.9301 0.2394 0.6261 0.2192 0.2326 0.2734 0.2611 0.4213 0.2864 0.0144 0.7449 0.0610 0.0759 0.6570 0.1742 0.0515 0.3413 0.9070 0.5861 0.0541 0.3573 0.5842 0.5757 0.8335 0.0589 0.1417 0.3956 0.6850 0.4733 0.4252 0.2488 0.0627 0.1731 0.9384 0.8288 0.1594 0.8072 0.7436 0.5631 0.3158 0.3322 0.9947 0.5693 0.9913 0.8987 0.8824 0.2489 0.3478 0.0953 0.9858 0.4353 0.9612 0.6869 0.2308 0.6285 0.2141 0.6214 0.4605 0.4264 0.2120 0.8636 0.5485 0.3003 0.5708 0.8084 0.3430 0.1389 0.5290 0.3177 0.5287 B(:,:,10) = 0.1313 0.4496 0.2976 0.5158 0.6339 0.5899 0.3844 0.3952 0.3134 0.4300 0.2740 0.2306 0.2939 0.9319 0.0362 0.1466 0.3632 0.8988 0.4072 0.0662 0.9047 0.9165 0.3303 0.7191 0.6065 0.1306 0.3958 0.2368 0.0688 0.0491 0.8971 0.3392 0.8594 0.1825 0.9770 0.0527 0.6409 0.8625 0.5921 0.3508 0.3373 0.5522 0.0881 0.0881 0.1696 0.0185 0.4544 0.7019 0.8056 0.3841 0.7284 0.5150 0.0230 0.4917 0.4564 0.1179 0.4694 0.3290 0.8194 0.4648 0.3084 0.7426 0.7482 0.4751 0.5044 0.5191 0.3165 0.8591 0.2706 0.3477 0.9396 0.2815 0.2041 0.5076 0.7233 0.0679 ...

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

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