Cody

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

Solution 2741149

Submitted on 26 Jul 2020 by Jessica
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.2464 0.2360 0.9005 0.5109 0.5835 0.4647 0.8824 0.3012 0.6307 0.8893 0.1212 0.2660 0.5194 0.9832 0.0194 0.4797 0.5951 0.4457 0.4243 0.0249 0.4347 0.1685 0.4735 0 0.7757 0.8492 0.4463 0.3609 0.7619 0.0276 0.8709 0.2300 0.0592 0.8751 0.9779 0.9587 0.7929 0.3551 0.9944 0.8362 0.4352 0.3180 0.0082 0.4536 0.6769 0.0747 0.8001 0.2125 0.2080 0.9217 0.1386 0.0306 0.8331 0.2744 0.4166 0.7929 0.1577 0.3740 0.3117 0.0764 0.4989 0.4354 0.6676 0.7332 0.1142 0.5292 0.8952 0.9144 0.2222 0.5554 0.4328 0.7913 0.0612 0.9201 0.7817 0.2446 0.4483 0.7740 0.1984 0.2806 0.3333 0.5300 0.4826 0.6708 0.6393 0.6736 0.5555 0.3359 0.8488 0.8282 0.7547 0.4334 0.4178 0.5424 0.6821 0.7483 0.2046 0.9718 0.7237 0.9003 B(:,:,2) = 0.6765 0 0.9262 0.1390 0.6527 0.6874 0.9927 0.0319 0.0055 0.7177 0.8555 0.4242 0.7281 0.9171 0.5674 0.8379 0.4883 0.8830 0.3538 0.3580 0.6373 0.0110 0.8578 0.2403 0.0293 0.7443 0.8073 0.0091 0.9221 0.9155 0.6402 0.5552 0.9924 0.4681 0.0951 0.3832 0.1458 0.1911 0.1268 0.8706 0.2512 0.9501 0.0317 0.4178 0.7775 0.0476 0.1115 0.4663 0.3195 0.8235 0.7455 0.2946 0.1616 0.8135 0.3548 0.2522 0.0560 0.6721 0.0257 0.9746 0.8548 0.5827 0.2366 0.8127 0.2679 0.2334 0.6172 0.5641 0.4450 0.4118 0.7982 0.4545 0.9433 0.0734 0.6975 0.9848 0.0689 0.8275 0.6373 0.8832 0.2466 0.4594 0.8023 0.7732 0.5862 0.7489 0.0235 0.4809 0.2161 0.0503 0.4479 0.1722 0.3034 0.2635 0.3621 0.8845 0.1932 0.7250 0.6986 0.4245 B(:,:,3) = 0.1532 0.7547 0.8373 0.9889 0.7165 0.0218 0.4606 0.6817 0.8315 0.8073 0.9958 0.4034 0.6941 0.1008 0.2769 0.4468 0.6234 0.0890 0.7609 0.0965 0.5834 0.0938 0.2056 0.8216 0.3311 0.4570 0.4279 0.7099 0.3600 0.3451 0.8346 0.2577 0.5570 0.9139 0.9109 0.9155 0.1524 0.1073 0.3424 0.0598 0.3358 0.7462 0.1707 0.5952 0.5660 0 0.3822 0.2195 0.9648 0.5719 0.4691 0.6426 0.4912 0.0503 0.9818 0.7833 0.5504 0.1414 0.8023 0.7458 0.4148 0.2292 0.7036 0.5759 0.3994 0.5065 0.0714 0.9292 0.3846 0.8712 0.0279 0.2771 0.4703 0.6122 0.3562 0.8904 0.9552 0.6539 0.9698 0.4928 0.9354 0.7711 0.8507 0.7423 0.1761 0.5685 0.7498 0.1489 0.5599 0.3869 0.7892 0.0732 0.7127 0.7318 0.3651 0.1584 0.2634 0.5892 0.5611 0.3648 B(:,:,4) = 0.6733 0.1330 0.5006 0.4002 0.1450 0.8600 0.6385 0.4620 0.1125 0.5556 0.2126 0.7267 0.5303 0.8970 0.3522 0.5413 0.4132 0.2457 0.5426 0.1564 0.8759 0.2967 0.8530 0.8732 0.0340 0.7942 0.9825 0.3340 0.5297 0.1523 0.9680 0.0717 0.4481 0.0769 0.9866 0.2591 0.3771 0.3687 0.0080 0.7621 0.5271 0.9822 0.3917 0.1589 0.5742 0.1470 0.6365 0.5172 0.6787 0.4942 0.1420 0.3296 0.3326 0.5920 0.0183 0.4626 0.8903 0.0248 0.7122 0.2389 0.7350 0.9761 0.6769 0.7894 0.2971 0.2341 0.9791 0.9383 0.8113 0.2740 0.4753 0.7542 0.5534 0.3355 0.7218 0.8160 0.1350 0.0687 0.2588 0.0391 0.6389 0.6044 0.9963 0.8785 0.7919 0.5464 0.9757 0.7775 0.1924 0.4340 0.1377 0.6868 0.7154 0.0524 0.5906 0.1797 0.4575 0.4683 0.9944 0.7565 B(:,:,5) = 0.9318 0.6895 0.5721 0.9948 0.4077 0.5091 0.4756 0.6557 0.7127 0.0681 0.1179 0.0024 0.4336 0.8123 0.2225 0.3527 0.7822 0.2835 0.8656 0.9451 0.8954 0.9113 0.1752 0.8336 0.7848 0.3980 0.8815 0.9056 0.7031 0.6630 0.0104 0.9768 0.4737 0.9981 0.3680 0.1380 0.6805 0.1103 0.9771 0.5080 0.0363 0.6152 0.0494 0.9893 0.8782 0.5353 0.8847 0.8914 0.2593 0.5870 0.2314 0.8421 0.6681 0.3348 0.7097 0.6818 0.5381 0.7048 0.7653 0.3964 0.9324 0.2469 0.3855 0.0383 0.3954 0.6507 0.2985 0.1528 0.1751 0.8151 0.8507 0.7526 0.3688 0.3778 0.6032 0.2729 0.1251 0.6225 0.6612 0.6909 0.9380 0.9330 0.9372 0.5431 0.2202 0.1941 0.0718 0.9375 0.3185 0.5819 0.7395 0.6850 0.8894 0.4673 0.6795 0.4957 0.6212 0.2208 0.6061 0.9865 B(:,:,6) = 0.9808 0.0822 0.1609 0.9389 0.3796 0.5368 0.5507 0.9476 0.6986 0.8229 0.9984 0.3056 0.2868 0.2028 0.3725 0.0880 0.4698 0.6203 0.2497 0.8617 0.3147 0.3304 0.9670 0.8377 0.5523 0.9747 0.2953 0.1050 0.6761 0.0472 0.4232 0.9923 0.1097 0.0443 0.3871 0.7669 0.1155 0.2484 0.9816 0.0643 0.7808 0.2046 0.6343 0.2985 0.7702 0.0106 0.1154 0.8292 0.8285 0.1244 0.4171 0.8775 0.7249 0.0129 0.0103 0.2215 0.8147 0.1489 0.1052 0.5353 0.3280 0.3919 0.6158 0.4787 0.2103 0.1193 0.8405 0.0282 0.3258 0.1983 0.7809 0.5408 0.1658 0.0074 0.2319 0.7621 0.0308 0.1487 0.2055 0.2073 0.7244 0.1725 0.8605 0.3116 0.8007 0.2126 0.6021 0.2311 0.8616 0.1157 0.4685 0.8382 0.6099 0.9421 0.2278 0.5293 0.1386 0.4991 0.7775 0.4463 B(:,:,7) = 0.3434 0.7679 0.6370 0.1124 0.1542 0.7783 0.3984 0.1295 0.2207 0.4781 0.0718 0.9983 0.9530 0.2286 0.8855 0.1320 0.9125 0.6616 0.7817 0.4490 0.1936 0.5476 0.6863 0.6485 0.2392 0.8415 0.6827 0.2314 0.7929 0.9438 0.5982 0.8846 0.4413 0.9424 0.2533 0.0513 0.9356 0.8539 0.4095 0.6583 0.8971 0.7637 0.2217 0.3343 0.9100 0.9804 0.2107 0.1344 0.5151 0.2577 0.1339 0.6375 0.5169 0.2287 0.0713 0.9235 0.6789 0.7741 0.0875 0.5656 0.3446 0.3637 0.8760 0.5140 0.1221 0.9409 0.3881 0.5225 0.2040 0.3106 0.1509 0.1660 0.3593 0.8829 0.2271 0.3469 0.2117 0.4648 0.1727 0.8626 0.9440 0.2651 0.7181 0.6786 0.4890 0.2738 0.5883 0.6692 0.2242 0.6663 0.2212 0.1533 0.3756 0.8205 0.1140 0.5712 0.5949 0.7494 0.2010 0.7160 B(:,:,8) = 0.4493 0.5813 0.7342 0.0398 0.6732 0.2419 0.5626 0.6629 0.6078 0.1336 0.9229 0.0585 0.9661 0.9322 0.9853 0.2860 0.7969 0.8165 0.3676 0.6899 0.5918 0.6468 0.3937 0.1948 0.9022 0.9754 0.9719 0.4232 0.5112 0.9625 0.8233 0.4102 0.0518 0.5125 0.9192 0.7377 0.0728 0.7244 0.2494 0.5565 0.0354 0.2792 0.9396 0.9277 0.4153 0.2409 0.2426 0.4475 0.5293 0.1149 0.7992 0.8628 0.5714 0.6007 0.0058 0.3770 0.5892 0.9612 0.2821 0.1831 0.0249 0.1342 0.4920 0.6235 0.3114 0.1545 0.9199 0.7402 0.4425 0.7982 0.6978 0.8901 0.3534 0.8154 0.4149 0.4473 0.5259 0.8338 0.9425 0.4040 0.2855 0.0717 0.4408 0.2347 0.8637 0.2613 0.8215 0.3204 0.6414 0.7120 0.3545 0.7983 0.1223 0.3590 0.6943 0.6594 0.0194 0.9758 0.1761 0.0199 B(:,:,9) = 0.3665 0.2614 0.4927 0.5305 0.8417 0.6743 0.6918 0.1862 0.2160 0.9139 0.9908 0.6024 0.2190 0.5892 0.3086 0.4914 0.6117 0.5140 0.5876 0.4886 0.4221 0.8834 0.2968 0.5758 0.6617 0.3801 0.4691 0.4563 0.2139 0.8295 0.7920 0.5509 0.9352 0.2445 0.7085 0.5868 0.6668 0.9160 0.3150 0.1364 0.3053 0.5291 0.2391 0.0743 0.3310 0.9955 0.8170 0.7691 0.0686 0.5023 0.9527 0.3116 0.4406 0.8641 0.5146 0.6518 0.4020 0.4022 0.9705 0.9759 0.2299 0.3244 0.7712 0.4598 0.7768 0.4575 0.9022 0.5635 0.9341 0.9027 0.7055 0.0284 0.8060 0.2673 0.8165 0.4126 0.3842 0.1011 0.1537 0.9064 0.5474 0.5092 0.9698 0.9476 0.0555 0.1153 0.0958 0.2954 0.1693 0.5431 0.6602 0.2341 0.3898 0.1428 0.0514 0.4862 0.8053 0.2329 0.4348 0.4255 B(:,:,10) = 0.0964 0.7617 0.4975 0.7432 0.0242 0.0962 0.1400 0.7748 0.3312 0.7723 0.2839 0.2576 0.2595 0.9654 0.2778 0.0038 0.2730 0.9318 0.7389 0.0175 0.8001 0.3681 0.7589 0.0726 0.8949 0.4304 0.4693 0.0018 0.5967 0.8228 0.0291 0.9982 0.6160 0.8201 0.9069 0.3353 0.8373 0.5929 0.0101 0.8117 0.4687 0.8164 0.4389 0.1602 0.5490 0.8906 0.1971 0.6235 0.1303 0.6980 0.8885 0.0003 0.4524 0.0547 0.4806 0.8392 0.6869 0.0031 0.4768 0.9116 0.0457 0.0393 0.1287 0.1801 0.8343 0.9610 0.3785 0.2814 0.2671 0.6527 0.2141 0.9667 0.5355 0.7669 0.9393 0.7329 ...

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

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