Cody

Solution 1890142

Submitted on 2 Aug 2019 by Steven Beumer
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.9699 0.6698 0.6255 0.5353 0.1776 0.9828 0.2185 0.1500 0.3891 0.1392 0.3831 0.1648 0.8494 0.6381 0.6704 0.3487 0.9343 0.8030 0.5456 0.5894 0.8556 0.6397 0.3809 0 0.1953 0.2803 0.4298 0.8369 0.7397 0.3656 0.5352 0.9255 0.0583 0.9418 0.2865 0.8036 0.4424 0.3069 0.1564 0.0603 0.6391 0.1965 0.3052 0.2610 0.1014 0.1006 0.6992 0.2628 0.3149 0.8894 0.6668 0.7951 0.4685 0.9718 0.5337 0.8127 0.9966 0.7279 0.8945 0.3365 0.2368 0.0031 0.3785 0.7351 0.1448 0.8658 0.6723 0.9321 0.7356 0.6832 0.7507 0.5324 0.2679 0.5447 0.3027 0.6047 0.5596 0.9634 0.4208 0.8457 0.7160 0.9461 0.7797 0.5979 0.0817 0.6871 0.2186 0.7217 0.2958 0.4832 0.7745 0.2993 0.6763 0.0125 0.4370 0.6747 0.5895 0.6861 0.3978 0.2090 A(:,:,2) = 0.7090 0 0.4359 0.0112 0.9471 0.7542 0.8938 0.8444 0.0746 0.2343 0.9887 0.5566 0.7384 0.4303 0.7221 0.6048 0.8383 0.1273 0.6144 0.7394 0.2315 0.7628 0.4983 0.1552 0.7073 0.6165 0.9883 0.0083 0.6244 0.5862 0.8885 0.7474 0.2896 0.6468 0.9819 0.3497 0.9692 0.2165 0.3368 0.1769 0.4331 0.4223 0.5688 0.5639 0.3316 0.0458 0.4472 0.7464 0.6485 0.2799 0.5162 0.0209 0.4923 0.1101 0.2342 0.4198 0.2999 0.0026 0.7259 0.9749 0.2343 0.5833 0.6670 0.9452 0.0781 0.6661 0.6182 0.4051 0.7654 0.1669 0.2897 0.1781 0.9160 0.4128 0.5724 0.6079 0.0977 0.1798 0.5467 0.3418 0.9575 0.0078 0.5892 0.1426 0.1844 0.6882 0.4469 0.0656 0.2628 0.9718 0.4101 0.5096 0.9947 0.3453 0.0466 0.6417 0.3915 0.6396 0.2058 0.1083 A(:,:,3) = 0.1047 0.2509 0.3884 0.4429 0.0683 0.0305 0.8337 0.4785 0.6889 0.5395 0.0280 0.6458 0.0782 0.8750 0.2678 0.6463 0.1662 0.5277 0.0950 0.1854 0.5719 0.2005 0.0152 0.9472 0.2515 0.1353 0.1801 0.0411 0.2282 0.2548 0.4776 0.8684 0.6042 0.6384 0.5148 0.1250 0.4173 0.1014 0.8203 0.7854 0.7636 0.1193 0.0084 0.6460 0.2826 0 0.7649 0.6376 0.2485 0.6816 0.9320 0.2803 0.3980 0.3608 0.8248 0.5113 0.0679 0.9105 0.5498 0.8052 0.3071 0.4975 0.4525 0.0066 0.2876 0.7955 0.7640 0.2104 0.4051 0.2633 0.8236 0.0168 0.7832 0.4592 0.8636 0.9908 0.6017 0.8860 0.6696 0.3688 0.6618 0.9577 0.8447 0.8257 0.3087 0.2371 0.1743 0.2978 0.8619 0.5904 0.9310 0.6644 0.4790 0.7605 0.0466 0.4114 0.4678 0.3283 0.2423 0.0075 A(:,:,4) = 0.3258 0.4702 0.2057 0.1928 0.1463 0.9646 0.4250 0.6127 0.1232 0.9943 0.9434 0.7692 0.7401 0.8830 0.5624 0.2102 0.1562 0.1515 0.2958 0.9457 0.3238 0.0971 0.2783 0.5495 0.1339 0.8235 0.9079 0.1617 0.2660 0.1255 0.6610 0.7309 0.9896 0.1523 0.1939 0.4547 0.0182 0.3187 0.6016 0.3675 0.3665 0.4257 0.5490 0.9777 0.9106 0.0134 0.9632 0.1553 0.5873 0.6197 0.5602 0.1593 0.7594 0.1350 0.4585 0.4349 0.2453 0.0518 0.7975 0.5594 0.2950 0.1820 0.0311 0.0469 0.0191 0.8028 0.5959 0.2433 0.9553 0.7366 0.1466 0.4665 0.3280 0.4280 0.4368 0.9938 0.9969 0.8953 0.0534 0.5993 0.8208 0.0295 0.6972 0.4962 0.9809 0.5531 0.7552 0.7352 0.9552 0.8635 0.7739 0.0969 0.9222 0.5962 0.6831 0.3976 0.2633 0.8582 0.5001 0.6458 A(:,:,5) = 0.4467 0.8792 0.0070 0.9450 0.2672 0.2067 0.9968 0.9295 0.9575 0.3304 0.0028 0.5791 0.5859 0.7721 0.0419 0.2396 0.4723 0.2336 0.2738 0.4819 0.9709 0.4062 0.5525 0.9618 0.1857 0.0416 0.3585 0.8523 0.3997 0.0181 0.6589 0.5847 0.4527 0.2943 0.3627 0.2231 0.7359 0.6291 0.1927 0.0003 0.4993 0.4641 0.2724 0.3387 0.3515 0.5992 0.5156 0.1561 0.3089 0.7734 0.3854 0.3714 0.0973 0.7508 0.6830 0.5098 0.9347 0.1961 0.9934 0.2906 0.2007 0.3181 0.0379 0.5809 0.5316 0.1364 0.3199 0.1134 0.6917 0.0851 0.6215 0.5550 0.2123 0.6470 0.2920 0.2860 0.5277 0.3860 0.1741 0.4880 0.6393 0.1460 0.5579 0.9614 0.8207 0.6825 0.1657 0.3128 0.3835 0.0419 0.9236 0.6708 0.6887 0.7073 0.6735 0.9866 0.8373 0.7658 0.5011 0.6720 A(:,:,6) = 0.4834 0.7458 0.7402 0.0560 0.9145 0.3278 0.2858 0.9801 0.8863 0.1695 0.3242 0.0223 0.1443 0.7074 0.9852 0.2111 0.9317 0.9917 0.1767 0.1296 0.3502 0.0644 0.1038 0.5496 0.4098 0.6717 0.5231 0.4862 0.5303 0.9567 0.6239 0.9446 0.1834 0.0017 0.7880 0.1418 0.1385 0.1916 0.4168 0.6102 0.0676 0.9017 0.6963 0.7804 0.9497 0.0439 0.2364 0.8694 0.0391 0.4626 0.6563 0.0254 0.6277 0.4979 0.6574 0.2673 0.5557 0.6518 0.6730 0.5054 0.0572 0.1397 0.1944 0.8865 0.7214 0.4694 0.9918 0.7142 0.5053 0.5882 0.2553 0.4015 0.4194 0.6291 0.0032 0.3514 0.5142 0.3664 0.8106 0.8453 0.0948 0.4754 0.4880 0.9986 0.0667 0.6229 0.5577 0.2437 0.0271 0.3594 0.1247 0.7270 0.7605 0.0085 0.8780 0.3320 0.2390 0.7182 0.8983 0.4315 A(:,:,7) = 0.3899 0.9341 0.6271 0.2364 0.7211 0.4324 0.7736 0.5341 0.8971 0.8462 0.4612 0.9859 0.4889 0.4244 0.7536 0.2509 0.0440 0.5705 0.6301 0.0359 0.9788 0.2684 0.2351 0.5811 0.5724 0.3375 0.7839 0.3659 0.2681 0.8974 0.1203 0.5194 0.3343 0.7551 0.2079 0.8396 0.3729 0.8044 0.4761 0.7916 0.4222 0.1189 0.0337 0.5639 0.6606 0.8743 0.5629 0.9688 0.9495 0.7986 0.8508 0.9480 0.3535 0.0722 0.4353 0.7913 0.7830 0.1724 0.5620 0.3285 0.4998 0.2087 0.8624 0.1280 0.4029 0.2496 0.3351 0.5247 0.7388 0.6233 0.6507 0.5867 0.1973 0.5594 0.3766 0.1101 0.9453 0.9665 0.9839 0.4630 0.7790 0.7764 0.4316 0.9727 0.5925 0.7256 0.5929 0.0034 0.1393 0.6639 0.2777 0.6954 0.2410 0.9603 0.0643 0.6624 0.6678 0.0745 0.0659 0.0561 A(:,:,8) = 0.4519 0.4077 0.3964 0.8194 0.1329 0.0144 0.0373 0.7614 0.8065 0.0620 0.5971 0.3239 0.7445 0.2984 0.2999 0.0405 0.7612 0.6787 0.7386 0.2381 0.4630 0.1576 0.1495 0.0065 0.7851 0.7963 0.3312 0.8153 0.9485 0.7721 0.9514 0.1806 0.4868 0.3416 0.2763 0.1821 0.4361 0.3590 0.2798 0.9894 0.2185 0.3735 0.6203 0.5683 0.0169 0.6252 0.1115 0.1124 0.1983 0.7748 0.7210 0.4579 0.5402 0.9938 0.9967 0.1451 0.0201 0.5674 0.3497 0.2147 0.6483 0.3601 0.8933 0.5580 0.2234 0.4856 0.5622 0.6654 0.1278 0.5469 0.8424 0.0782 0.2780 0.8655 0.7799 0.0850 0.4731 0.5492 0.9029 0.1171 0.3137 0.0293 0.6438 0.4662 0.7351 0.7542 0.8236 0.6341 0.9195 0.9850 0.7692 0.1695 0.4790 0.8556 0.5607 0.9398 0.8349 0.7329 0.8465 0.2350 A(:,:,9) = 0.9682 0.6128 0.1233 0.0800 0.0785 0.1488 0.9388 0.7068 0.7964 0.7473 0.9068 0.9511 0.9593 0.4938 0.7930 0.6760 0.6563 0.7077 0.1023 0.0030 0.8303 0.2280 0.5364 0.9103 0.5136 0.6116 0.7552 0.1218 0.2627 0.9627 0.5616 0.7178 0.9196 0.0418 0.9723 0.5865 0.6185 0.2455 0.2646 0.4490 0.4132 0.9960 0.4938 0.6984 0.6047 0.1687 0.6406 0.6692 0.8997 0.0618 0.5018 0.0934 0.4487 0.2592 0.7196 0.5368 0.0203 0.4551 0.9691 0.4387 0.4206 0.8884 0.4328 0.4177 0.6762 0.8029 0.8501 0.4324 0.2685 0.9901 0.3009 0.6384 0.8103 0.6908 0.2310 0.8757 0.8589 0.9066 0.2456 0.2395 0.6647 0.5568 0.7618 0.3267 0.2144 0.6982 0.8095 0.2882 0.9718 0.8148 0.3921 0.7300 0.4040 0.9454 0.0238 0.2633 0.0384 0.1868 0.6468 0.0579 A(:,:,10) = 0.8262 0.8874 0.4299 0.1498 0.2669 0.6046 0.2755 0.6514 0.6948 0.0757 0.2670 0.9042 0.2025 0.8074 0.5133 0.9375 0.8868 0.9799 0.8178 0.7452 0.3707 0.3824 0.9554 0.5468 0.9347 0.3176 0.4618 0.2841 0.5552 0.1717 0.4917 0.3245 0.8910 0.7780 0.9840 0.0306 0.8653 0.3989 0.5213 0.0288 0.3621 0.4854 0.6541 0.5989 0.3439 0.8482 0.0344 0.9677 0.6739 0.0988 0.6685 0.2053 0.1117 0.2328 0.4509 0.0224 0.3879 0.8291 0.4474 0.4994 0.6041 0.3219 0.6622 0.6386 0.6427 0.5224 0.6255 0.2537 0.4717 0.1297 0.5342 0.3291 0.9593 0.3787 0.9210 0.6455 ...

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

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