Cody

Solution 1846793

Submitted on 11 Jun 2019 by Magid Mostafa
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.3398 0.2229 0.2593 0.2765 0.2910 0.1111 0.4571 0.1656 0.6739 0.4156 0.5424 0.8648 0.5367 0.6776 0.6726 0.9909 0.2276 0.1103 0.9568 0.6916 0.8197 0.0899 0.1139 0 0.0862 0.7466 0.2257 0.7581 0.0460 0.9030 0.3890 0.8260 0.8497 0.5499 0.6130 0.4752 0.9121 0.3704 0.3352 0.6450 0.5735 0.5367 0.5955 0.0661 0.1916 0.0597 0.6055 0.0089 0.6704 0.0420 0.0097 0.1167 0.1804 0.0596 0.5398 0.4648 0.7397 0.1256 0.0486 0.7709 0.3447 0.3297 0.2577 0.2541 0.5422 0.3891 0.9714 0.9657 0.1693 0.6982 0.8965 0.6029 0.9420 0.8956 0.6803 0.8861 0.4790 0.1048 0.7386 0.8901 0.8518 0.5464 0.8107 0.8781 0.8157 0.9122 0.3267 0.3410 0.2772 0.9746 0.4888 0.6771 0.6152 0.6320 0.7709 0.6293 0.6217 0.2420 0.3629 0.8324 A(:,:,2) = 0.3204 0 0.2364 0.4885 0.6621 0.8919 0.8735 0.6395 0.8448 0.9163 0.4139 0.7171 0.4029 0.7602 0.2945 0.5231 0.8236 0.7026 0.6764 0.1856 0.4665 0.8344 0.6848 0.3652 0.7015 0.5835 0.2332 0.4405 0.8719 0.0146 0.0123 0.2005 0.2782 0.3976 0.1340 0.3211 0.1699 0.7104 0.8631 0.7152 0.0070 0.0742 0.0572 0.0006 0.1143 0.1889 0.8595 0.0752 0.1230 0.1728 0.5359 0.2156 0.2425 0.9047 0.9387 0.9801 0.6751 0.0575 0.8772 0.9126 0.6596 0.9298 0.5893 0.7729 0.6084 0.3859 0.8379 0.2764 0.1744 0.1767 0.1416 0.1112 0.7546 0.2411 0.9763 0.0962 0.3868 0.8833 0.2040 0.5432 0.7722 0.1778 0.8062 0.7865 0.4088 0.6119 0.2058 0.9986 0.6817 0.3016 0.7148 0.0138 0.2088 0.2679 0.5994 0.4346 0.2327 0.3233 0.3149 0.6043 A(:,:,3) = 0.9473 0.9654 0.4641 0.7081 0.5967 0.7791 0.2517 0.7970 0.9810 0.5363 0.1956 0.6509 0.1058 0.8110 0.7347 0.3741 0.1794 0.0711 0.2150 0.9754 0.6241 0.1642 0.0570 0.6496 0.1292 0.0064 0.2012 0.8251 0.9085 0.3188 0.3910 0.2752 0.9419 0.4337 0.9774 0.5323 0.5401 0.7605 0.5038 0.0441 0.5393 0.5962 0.4871 0.4128 0.3381 0 0.6173 0.8227 0.0204 0.8881 0.3972 0.3643 0.3497 0.9647 0.0027 0.0272 0.1847 0.7545 0.6632 0.7652 0.7379 0.6647 0.7378 0.0419 0.2147 0.9723 0.1792 0.1677 0.4775 0.9295 0.5179 0.8314 0.1214 0.7091 0.3947 0.6626 0.1808 0.6227 0.8521 0.2642 0.0178 0.8747 0.5607 0.2508 0.5622 0.7619 0.2779 0.7164 0.9604 0.9597 0.9081 0.9787 0.7757 0.8592 0.2443 0.9257 0.8741 0.7076 0.6839 0.7033 A(:,:,4) = 0.2316 0.4715 0.2001 0.1931 0.4642 0.5726 0.1749 0.8761 0.7147 0.2536 0.2719 0.1767 0.2709 0.2255 0.3215 0.5161 0.3724 0.5541 0.0674 0.8932 0.4409 0.8161 0.7158 0.8188 0.7458 0.9460 0.1855 0.4518 0.3290 0.3449 0.4072 0.1034 0.6083 0.9484 0.3758 0.8520 0.3003 0.0614 0.8178 0.7525 0.5462 0.3015 0.9854 0.3947 0.2494 0.0883 0.8299 0.6966 0.9518 0.3967 0.8395 0.4044 0.8424 0.3952 0.8498 0.6494 0.2336 0.8937 0.7850 0.2992 0.6369 0.3844 0.0080 0.2393 0.1005 0.4595 0.1836 0.1622 0.2702 0.1034 0.2370 0.7059 0.6984 0.1854 0.1564 0.4634 0.1768 0.4814 0.4233 0.1309 0.5784 0.7172 0.0955 0.1265 0.1947 0.1174 0.7142 0.6955 0.8587 0.0204 0.7700 0.9820 0.7562 0.1960 0.0966 0.1752 0.1054 0.3410 0.8240 0.6476 A(:,:,5) = 0.4257 0.6986 0.3096 0.5420 0.1477 0.6480 0.6015 0.5751 0.1991 0.2569 0.7174 0.2397 0.0190 0.9968 0.9625 0.9875 0.1915 0.2683 0.4874 0.7323 0.1319 0.2802 0.7756 0.3604 0.9660 0.9417 0.2009 0.6533 0.0159 0.6315 0.8727 0.1452 0.8979 0.0875 0.6021 0.8592 0.5153 0.2647 0.2824 0.2710 0.0185 0.8193 0.9735 0.3988 0.4729 0.1927 0.4213 0.9461 0.7041 0.2445 0.9875 0.0126 0.0588 0.0204 0.8982 0.6021 0.2630 0.4366 0.4263 0.6137 0.3323 0.1188 0.9124 0.4415 0.1984 0.0460 0.2621 0.9057 0.2695 0.3216 0.3481 0.4620 0.4897 0.4313 0.6761 0.9071 0.2212 0.7437 0.6270 0.2341 0.4668 0.4264 0.9706 0.2282 0.1236 0.4515 0.6071 0.8578 0.1585 0.0243 0.4724 0.0818 0.5400 0.7371 0.4610 0.3984 0.8302 0.8734 0.2680 0.2961 A(:,:,6) = 0.9997 0.8596 0.9157 0.7155 0.6611 0.8980 0.0348 0.6133 0.9298 0.8082 0.7081 0.9145 0.3009 0.5558 0.8639 0.7747 0.5581 0.2140 0.0277 0.7842 0.9433 0.2282 0.9475 0.5270 0.0787 0.6251 0.1664 0.7529 0.6945 0.2437 0.6105 0.6213 0.2124 0.9811 0.3756 0.2700 0.6782 0.9927 0.4638 0.9293 0.7853 0.3362 0.3567 0.5081 0.7673 0.3853 0.1493 0.3010 0.9371 0.4057 0.2504 0.9075 0.4754 0.0638 0.3090 0.7465 0.1464 0.4853 0.3656 0.4464 0.7423 0.1835 0.8182 0.4685 0.8916 0.6169 0.1854 0.5373 0.2145 0.0067 0.0963 0.0340 0.0653 0.9785 0.9883 0.7959 0.1735 0.6452 0.0476 0.3588 0.0191 0.7684 0.8419 0.5889 0.7903 0.5118 0.5104 0.4937 0.1613 0.0981 0.8976 0.5690 0.1695 0.5915 0.7351 0.9547 0.0758 0.5651 0.2850 0.6818 A(:,:,7) = 0.1451 0.5535 0.1773 0.3496 0.6811 0.3965 0.4967 0.3666 0.8644 0.2486 0.9618 0.4354 0.8802 0.6366 0.8512 0.9946 0.0187 0.7165 0.7589 0.1045 0.1637 0.7463 0.0881 0.7156 0.6338 0.0126 0.6605 0.9859 0.0497 0.9328 0.1297 0.0291 0.4076 0.5577 0.7577 0.6344 0.9386 0.3375 0.0713 0.2078 0.8646 0.9794 0.4572 0.4222 0.4700 0.8633 0.3705 0.0072 0.4225 0.1691 0.6172 0.4637 0.4250 0.3548 0.7727 0.8919 0.8551 0.3941 0.9665 0.0397 0.4751 0.2173 0.3300 0.6421 0.4948 0.1732 0.5030 0.4732 0.9431 0.6858 0.6532 0.9328 0.2131 0.6636 0.4569 0.2559 0.9696 0.1668 0.4231 0.4856 0.7156 0.6682 0.7353 0.0478 0.0358 0.5814 0.0575 0.5389 0.6307 0.5280 0.7247 0.0940 0.2471 0.9141 0.6891 0.2547 0.8652 0.4616 0.8777 0.5182 A(:,:,8) = 0.9222 0.8259 0.5593 0.0099 0.2027 0.5648 0.9765 0.7005 0.4221 0.8351 0.0677 0.9110 0.9433 0.0771 0.5895 0.6790 0.5562 0.9307 0.2662 0.2300 0.4310 0.6455 0.0890 0.3804 0.3814 0.2552 0.9279 0.5852 0.5141 0.9794 0.0691 0.7372 0.3139 0.2205 0.3547 0.0448 0.7644 0.3885 0.8732 0.7951 0.7992 0.7026 0.9576 0.7779 0.3843 0.1479 0.3425 0.4934 0.5303 0.6777 0.1994 0.0130 0.4910 0.7647 0.4876 0.2545 0.5936 0.3579 0.6223 0.9328 0.3951 0.7633 0.8196 0.1763 0.3833 0.8775 0.4569 0.5689 0.7528 0.6207 0.2038 0.8110 0.1676 0.5753 0.4283 0.4644 0.3817 0.5722 0.9564 0.2329 0.5383 0.7061 0.4868 0.0091 0.8675 0.1901 0.5457 0.1186 0.0480 0.0994 0.2756 0.7747 0.1058 0.3922 0.7830 0.1747 0.3829 0.4321 0.6664 0.1755 A(:,:,9) = 0.4659 0.7769 0.2863 0.9186 0.3526 0.5946 0.0743 0.9695 0.6991 0.1716 0.1501 0.8936 0.3919 0.2647 0.6549 0.8884 0.8103 0.7264 0.7025 0.2294 0.8159 0.0521 0.9479 0.7179 0.7613 0.6464 0.3452 0.2643 0.8515 0.2762 0.5779 0.4772 0.5798 0.7979 0.7846 0.0157 0.8554 0.3938 0.6176 0.8365 0.0183 0.3478 0.1050 0.5473 0.3063 0.4241 0.5981 0.3663 0.2320 0.5385 0.2478 0.0242 0.8321 0.6721 0.4962 0.6704 0.3698 0.0717 0.1963 0.3105 0.9287 0.7911 0.5865 0.3557 0.4909 0.7139 0.2058 0.4543 0.7714 0.8093 0.0781 0.9295 0.3268 0.6209 0.3928 0.5888 0.0452 0.3548 0.7576 0.9131 0.8065 0.6173 0.3031 0.5919 0.1878 0.7097 0.9037 0.8059 0.3974 0.3790 0.4515 0.5522 0.4336 0.2997 0.3620 0.5767 0.9012 0.7952 0.9579 0.6078 A(:,:,10) = 0.3996 0.2014 0.3621 0.0780 0.2956 0.3897 0.2739 0.4165 0.9657 0.8120 0.6019 0.0103 0.7178 0.9110 0.3340 0.4665 0.8416 0.3577 0.3448 0.6269 0.9475 0.5726 0.7730 0.1108 0.2815 0.2604 0.4652 0.7430 0.2573 0.0358 0.7377 0.7761 0.8369 0.6648 0.4963 0.3907 0.3544 0.8051 0.5868 0.9779 0.0082 0.4628 0.8610 0.1228 0.2555 0.1762 0.1408 0.5277 0.9224 0.8174 0.6282 0.1779 0.0120 0.7960 0.2471 0.0403 0.6645 0.8315 0.0853 0.9452 0.6460 0.0567 0.8467 0.6780 0.9448 0.8102 0.4423 0.7957 0.3199 0.5237 0.1814 0.5270 0.6919 0.5384 0.6501 0.9713 ...

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

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