Cody

Solution 340996

Submitted on 28 Oct 2013 by Mark Hanus
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
%% test 1 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
%% test 2 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
%% test 3 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
%% test 4 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
%% test 5 with a multidimensional array 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.4292 0.8501 0.4187 0.0385 0.4969 0.9872 0.7916 0.5277 0.2060 0.3988 0.2465 0.1254 0.0457 0.5369 0.8501 0.9915 0.4395 0.8792 0.0215 0.1883 0.4821 0.9224 0.8626 0 0.3751 0.5290 0.1745 0.9052 0.0260 0.1559 0.8701 0.1843 0.4340 0.3145 0.2409 0.2837 0.4408 0.0170 0.8482 0.7732 0.6971 0.6103 0.9833 0.9624 0.5053 0.8905 0.8474 0.0163 0.5958 0.9207 0.7977 0.2397 0.1953 0.3091 0.4668 0.9028 0.7474 0.7182 0.4483 0.9254 0.3904 0.0343 0.6594 0.9287 0.5801 0.7283 0.7252 0.9511 0.6483 0.0188 0.8564 0.8921 0.8961 0.0856 0.2702 0.1550 0.0105 0.9084 0.5534 0.6379 0.3780 0.9892 0.8179 0.4599 0.7095 0.9038 0.9496 0.7058 0.5658 0.8881 0.7140 0.0733 0.0655 0.3162 0.1314 0.4054 0.7826 0.7168 0.8306 0.9804 A(:,:,2) = 0.3395 0 0.6586 0.6857 0.0263 0.3638 0.6590 0.2642 0.6044 0.2078 0.6509 0.9490 0.4642 0.5702 0.2109 0.1713 0.5762 0.1725 0.9185 0.2502 0.1222 0.5792 0.2158 0.0339 0.0205 0.3832 0.3440 0.9870 0.8162 0.0781 0.1946 0.9288 0.5621 0.4012 0.0791 0.2479 0.9450 0.9967 0.8356 0.2011 0.7632 0.3118 0.9847 0.2830 0.5779 0.8961 0.0945 0.0682 0.4220 0.5797 0.8052 0.1999 0.0218 0.2208 0.3222 0.2918 0.0667 0.8848 0.2272 0.7487 0.5749 0.4497 0.7454 0.5107 0.1746 0.9639 0.6283 0.5829 0.6910 0.7698 0.7953 0.3990 0.7129 0.0786 0.3814 0.4931 0.1753 0.3883 0.4389 0.5729 0.4505 0.6959 0.6724 0.9960 0.7465 0.6164 0.8782 0.1199 0.8275 0.5466 0.2666 0.3450 0.9817 0.3229 0.1767 0.8712 0.6305 0.3444 0.0141 0.1751 A(:,:,3) = 0.9992 0.0677 0.1665 0.6818 0.3907 0.8357 0.1932 0.3343 0.4651 0.6601 0.8989 0.4108 0.4208 0.1497 0.5637 0.5032 0.7677 0.8452 0.5017 0.0025 0.8203 0.0951 0.7695 0.1097 0.2799 0.8351 0.3144 0.9526 0.2476 0.7507 0.1144 0.7705 0.3581 0.8246 0.8916 0.9690 0.2579 0.6559 0.9600 0.3563 0.8973 0.3587 0.1514 0.8755 0.6863 0 0.7465 0.9305 0.1679 0.7339 0.1604 0.8802 0.8565 0.7437 0.1029 0.5619 0.6904 0.2851 0.2171 0.1874 0.1098 0.2971 0.5611 0.0807 0.0852 0.1082 0.3426 0.0869 0.8343 0.0938 0.7708 0.7367 0.6238 0.6492 0.0626 0.9829 0.3454 0.7277 0.9860 0.5646 0.5088 0.4749 0.9286 0.2952 0.6927 0.2037 0.9467 0.9639 0.8024 0.2764 0.8748 0.0865 0.9726 0.1388 0.9696 0.8233 0.0263 0.7320 0.4938 0.2351 A(:,:,4) = 0.2908 0.7336 0.8069 0.6596 0.5589 0.7884 0.7002 0.6982 0.7209 0.3213 0.8013 0.7040 0.9971 0.1283 0.4802 0.2800 0.5797 0.4652 0.4170 0.4711 0.8306 0.2994 0.9529 0.9735 0.2422 0.5283 0.9310 0.0818 0.5380 0.5496 0.3937 0.8301 0.7610 0.7707 0.6045 0.3376 0.1486 0.2008 0.8386 0.4941 0.9518 0.0691 0.9203 0.5599 0.8777 0.6407 0.2405 0.6521 0.9358 0.4220 0.5237 0.6566 0.9224 0.1462 0.7499 0.9426 0.8260 0.7950 0.7048 0.3583 0.5680 0.7919 0.0059 0.8051 0.2266 0.9395 0.5146 0.7913 0.8776 0.2342 0.6876 0.1200 0.9956 0.0036 0.0990 0.7742 0.5520 0.8182 0.4440 0.3804 0.0398 0.5594 0.7500 0.3260 0.1204 0.4255 0.1949 0.1058 0.9407 0.0312 0.5339 0.6701 0.8564 0.7956 0.2114 0.9113 0.5022 0.8733 0.5094 0.6626 A(:,:,5) = 0.1400 0.1541 0.9079 0.2745 0.0224 0.5948 0.0502 0.9532 0.7945 0.7463 0.3099 0.2231 0.3767 0.2544 0.4317 0.9173 0.8738 0.2322 0.4634 0.8825 0.8384 0.1600 0.3580 0.3209 0.0396 0.5813 0.5783 0.9405 0.9871 0.8949 0.0349 0.9254 0.1059 0.3966 0.2914 0.6989 0.2342 0.1830 0.8427 0.0871 0.0397 0.0053 0.4777 0.8868 0.0448 0.7741 0.7754 0.8675 0.7547 0.6423 0.9645 0.4500 0.1513 0.3523 0.7270 0.6120 0.5595 0.5859 0.7565 0.1924 0.6448 0.9165 0.3085 0.8458 0.8224 0.4489 0.2628 0.1533 0.9308 0.1801 0.9692 0.9950 0.9429 0.1434 0.6938 0.8125 0.0843 0.6973 0.6638 0.3813 0.3163 0.5187 0.9171 0.6104 0.8629 0.3365 0.2774 0.9507 0.8042 0.6824 0.8109 0.5805 0.5396 0.7289 0.1815 0.9757 0.7379 0.3614 0.7110 0.3482 A(:,:,6) = 0.9713 0.2109 0.8526 0.1522 0.9725 0.4679 0.0948 0.3958 0.6073 0.8211 0.1163 0.2512 0.4079 0.2480 0.1554 0.7696 0.1107 0.8981 0.4409 0.6513 0.0899 0.9446 0.1620 0.6913 0.3571 0.4006 0.2113 0.9539 0.6652 0.2548 0.2005 0.5784 0.5854 0.7149 0.4449 0.1733 0.4078 0.7007 0.0073 0.9471 0.9726 0.7867 0.5122 0.2650 0.1861 0.9106 0.2772 0.5705 0.1323 0.2072 0.0804 0.6855 0.0663 0.4744 0.0129 0.1101 0.2607 0.3059 0.7800 0.3548 0.8954 0.5172 0.5845 0.5626 0.0615 0.2914 0.3717 0.6975 0.0641 0.1933 0.1112 0.6689 0.7714 0.0952 0.9375 0.0506 0.5656 0.7150 0.5049 0.5635 0.7105 0.7875 0.8215 0.8155 0.0820 0.0650 0.9801 0.7713 0.6124 0.8437 0.8419 0.7012 0.1358 0.3412 0.3775 0.9704 0.3633 0.1055 0.3685 0.6995 A(:,:,7) = 0.1471 0.8124 0.1956 0.8938 0.2283 0.9177 0.9000 0.1963 0.1426 0.9112 0.9279 0.5384 0.8256 0.8005 0.3243 0.2395 0.8347 0.4534 0.8685 0.2742 0.4986 0.5635 0.3847 0.3911 0.9980 0.3676 0.4021 0.0797 0.6298 0.0223 0.1560 0.9942 0.1579 0.1778 0.9584 0.9122 0.2481 0.3228 0.4398 0.4157 0.5658 0.3820 0.3935 0.4701 0.0529 0.8733 0.2294 0.5468 0.4321 0.6153 0.7002 0.9039 0.2902 0.6825 0.2901 0.6519 0.8934 0.0967 0.8168 0.1833 0.0315 0.0181 0.1527 0.5368 0.2583 0.8369 0.0486 0.9240 0.6800 0.7333 0.8484 0.4159 0.3100 0.0970 0.8292 0.7911 0.8775 0.6101 0.9436 0.8126 0.7139 0.4274 0.9507 0.8367 0.1525 0.2718 0.8467 0.4559 0.8294 0.7825 0.1332 0.9515 0.5577 0.3266 0.3139 0.5987 0.6835 0.5914 0.9454 0.6122 A(:,:,8) = 0.1371 0.3838 0.2537 0.4429 0.7490 0.0925 0.0963 0.8043 0.1210 0.6144 0.2582 0.0885 0.7116 0.0144 0.1688 0.1609 0.0921 0.5269 0.7792 0.7130 0.8558 0.3587 0.3716 0.3023 0.8415 0.3879 0.4079 0.1740 0.5014 0.7196 0.7677 0.9141 0.4205 0.4580 0.7921 0.2402 0.6128 0.4330 0.2788 0.6363 0.6763 0.8557 0.6340 0.8066 0.4027 0.5510 0.9212 0.6710 0.1698 0.9259 0.8283 0.5077 0.7037 0.9180 0.4840 0.1024 0.9087 0.2719 0.7502 0.2717 0.4478 0.4300 0.6258 0.0853 0.2140 0.2344 0.2933 0.3765 0.6319 0.2878 0.5898 0.9687 0.4615 0.0414 0.2042 0.8987 0.6436 0.8924 0.3000 0.7452 0.5652 0.2598 0.2836 0.9923 0.0899 0.9231 0.3105 0.3841 0.7105 0.2138 0.4561 0.1240 0.2265 0.7717 0.8282 0.7460 0.4655 0.9074 0.4457 0.6535 A(:,:,9) = 0.8645 0.0405 0.0756 0.1876 0.0560 0.3462 0.9423 0.0105 0.4890 0.5732 0.0463 0.9739 0.9288 0.4648 0.8838 0.8557 0.8560 0.8762 0.4563 0.5473 0.4695 0.7277 0.3392 0.3099 0.8238 0.9833 0.5085 0.9582 0.5912 0.9025 0.2575 0.1828 0.6344 0.1344 0.4195 0.1129 0.0782 0.9498 0.7511 0.7979 0.9415 0.8741 0.1131 0.7718 0.6407 0.8597 0.0565 0.7410 0.7351 0.6939 0.5836 0.7496 0.3437 0.9919 0.0498 0.8869 0.2654 0.5485 0.5559 0.1105 0.5150 0.7184 0.6433 0.2158 0.3495 0.9218 0.1436 0.1798 0.2604 0.1813 0.0557 0.2776 0.4538 0.1699 0.7891 0.6224 0.8533 0.7378 0.2146 0.2901 0.8338 0.0722 0.6911 0.0777 0.6391 0.6599 0.4336 0.9672 0.2393 0.1655 0.0137 0.4139 0.9217 0.5755 0.1586 0.6593 0.1288 0.1508 0.2095 0.9448 A(:,:,10) = 0.4702 0.9186 0.8601 0.6195 0.3123 0.8628 0.6857 0.7738 0.6448 0.0312 0.0787 0.2257 0.9748 0.0264 0.3635 0.8203 0.2484 0.9670 0.8359 0.3381 0.5628 0.9449 0.2211 0.5569 0.0696 0.2495 0.5724 0.5656 0.3594 0.3773 0.5304 0.7373 0.3344 0.8671 0.9990 0.5248 0.1360 0.2121 0.6079 0.0716 0.4337 0.4713 0.8381 0.0413 0.6033 0.4606 0.0689 0.4587 0.8010 0.1794 0.6741 0.3350 0.3103 0.3309 0.9899 0.2251 0.6986 0.0936 0.7298 0.9785 0.3576 0.1352 0.7246 0.8999 0.5773 0.1307 0.6379 0.8745 0.5040 0.0934 0.6134 0.5781 0.4516 0.8476 0.1859 0.1101 0.7769 0.5025 0.8027 ...

6   Pass
%% test 6 repmat ! 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 = Columns 1 through 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 Column 17 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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
%% test 7 magic! 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
%% test 8 floating (maybe people will work with string recognition) A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

A = 13.3000