Cody

Solution 764067

Submitted on 18 Oct 2015 by Raviteja
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) = Columns 1 through 9 0.2551 0.6987 0.5704 0.9121 0.8588 0.4998 0.6348 0.6010 0.9272 0.2389 0.3548 0.3419 0.5946 0.5359 0.4458 0.0536 0.0640 0.5047 0.1199 0.4669 0.6933 0 0.4305 0.6249 0.6891 0.9045 0.2182 0.5094 0.6138 0.1869 0.2684 0.3431 0.4189 0.1000 0.1307 0.8343 0.0018 0.0134 0.5774 0.6052 0.9173 0.6527 0.1952 0.6861 0.5750 0.8700 0.4615 0.6576 0.1268 0.9806 0.7282 0.4422 0.4678 0.9150 0.6276 0.4870 0.9319 0.8645 0.4603 0.3459 0.0264 0.0247 0.0433 0.9633 0.3462 0.0333 0.4867 0.6034 0.7436 0.9748 0.6365 0.0396 0.1112 0.6415 0.5446 0.6697 0.7859 0.5107 0.4352 0.7157 0.1015 0.8020 0.9149 0.6842 0.9132 0.8454 0.5122 0.7737 0.6129 0.3633 Column 10 0.2526 0.7840 0.5969 0.9908 0.7572 0.7460 0.1974 0.9839 0.9835 0.9231 A(:,:,2) = Columns 1 through 9 0.2316 0 0.9677 0.8961 0.5581 0.7343 0.8228 0.7118 0.6342 0.6489 0.2293 0.7012 0.9026 0.7593 0.9602 0.9079 0.1225 0.8185 0.2044 0.8781 0.3658 0.2394 0.4146 0.4486 0.2473 0.3733 0.8651 0.3916 0.1478 0.5534 0.0051 0.8704 0.2167 0.9161 0.1056 0.7279 0.2082 0.6056 0.2195 0.1728 0.4804 0.2351 0.7578 0.8296 0.1679 0.5970 0.4402 0.9892 0.7980 0.7608 0.2189 0.7303 0.6421 0.9338 0.0987 0.7662 0.3071 0.1188 0.3644 0.3733 0.3728 0.1027 0.7703 0.9640 0.0189 0.5795 0.3301 0.6616 0.3597 0.4770 0.7857 0.6487 0.6925 0.6504 0.2784 0.3075 0.3238 0.6660 0.5086 0.0992 0.4217 0.5665 0.0803 0.5500 0.2252 0.5724 0.1204 0.6176 0.4333 0.7150 Column 10 0.1530 0.7864 0.4642 0.3031 0.2994 0.4311 0.3845 0.7496 0.1317 0.9784 A(:,:,3) = Columns 1 through 9 0.4184 0.6028 0.5248 0.2575 0.0188 0.0358 0.4203 0.4954 0.0093 0.4174 0.6426 0.5609 0.5622 0.0406 0.2265 0.0063 0.7139 0.9006 0.7074 0.5561 0.7222 0.0563 0.6849 0.4197 0.5049 0.4882 0.7189 0.7233 0.1215 0.6444 0.3097 0.2391 0.7421 0.8347 0.9280 0.4622 0.8358 0.6859 0.4625 0.5661 0.3558 0 0.6365 0.8204 0.0526 0.0616 0.4751 0.6719 0.3880 0.4522 0.1365 0.1831 0.2186 0.0088 0.1845 0.7907 0.6136 0.9583 0.8955 0.4462 0.9973 0.7666 0.3656 0.1377 0.3891 0.2434 0.8791 0.6253 0.6339 0.8636 0.9417 0.6625 0.9187 0.9466 0.9325 0.7550 0.1198 0.2732 0.8139 0.9218 0.8130 0.7920 0.6826 0.0866 0.0510 0.5696 0.3015 0.6623 0.2935 0.2327 Column 10 0.9754 0.9105 0.4809 0.8391 0.9316 0.9141 0.2953 0.8698 0.3509 0.9327 A(:,:,4) = Columns 1 through 9 0.4645 0.9714 0.8057 0.9830 0.4117 0.8887 0.7482 0.9868 0.4881 0.2094 0.3847 0.1988 0.5120 0.6272 0.0530 0.1036 0.6912 0.7222 0.8590 0.5469 0.3734 0.0861 0.7214 0.0241 0.2449 0.7243 0.8587 0.7080 0.7000 0.7267 0.0360 0.3944 0.8591 0.5322 0.3340 0.0222 0.7396 0.0751 0.3529 0.1252 0.1227 0.4317 0.4821 0.6338 0.4581 0.5043 0.0934 0.9284 0.6888 0.8999 0.3227 0.9577 0.8123 0.1387 0.7570 0.9626 0.5474 0.6920 0.5638 0.3532 0.2686 0.6998 0.7858 0.1926 0.1524 0.4906 0.2425 0.2900 0.6793 0.0605 0.9648 0.3894 0.3638 0.7706 0.4001 0.8911 0.0935 0.0622 0.0574 0.9037 0.5029 0.9587 0.8291 0.0888 0.3979 0.2043 0.4218 0.8819 0.3506 0.8292 Column 10 0.1482 0.9652 0.8223 0.2729 0.5314 0.5461 0.2289 0.0641 0.9040 0.3723 A(:,:,5) = Columns 1 through 9 0.5747 0.0143 0.1679 0.2076 0.9652 0.7304 0.6725 0.4787 0.0436 0.9288 0.3135 0.0222 0.9124 0.4002 0.2545 0.9047 0.3412 0.2632 0.8808 0.6581 0.5349 0.1631 0.9541 0.3623 0.9346 0.1191 0.0812 0.6626 0.3581 0.1842 0.7140 0.8747 0.4193 0.9559 0.2509 0.0467 0.9115 0.1472 0.7761 0.2944 0.2152 0.9327 0.0867 0.5528 0.1917 0.2746 0.1999 0.4417 0.0588 0.6041 0.7083 0.0042 0.1599 0.9306 0.3400 0.1747 0.0514 0.4213 0.3278 0.0184 0.6040 0.7880 0.0625 0.3002 0.0667 0.0953 0.9784 0.0826 0.6354 0.9730 0.3159 0.2235 0.5083 0.3846 0.8134 0.1461 0.7884 0.8517 0.3711 0.7658 0.1942 0.3634 0.5845 0.8840 0.6145 0.7411 0.4940 0.7589 0.4024 0.8501 Column 10 0.1458 0.4797 0.1960 0.5059 0.9758 0.4724 0.3046 0.0735 0.0816 0.5408 A(:,:,6) = Columns 1 through 9 0.5970 0.2686 0.7394 0.7137 0.7725 0.3917 0.0227 0.4060 0.0603 0.6069 0.4444 0.4010 0.7935 0.8738 0.6806 0.6631 0.0775 0.7988 0.3807 0.9665 0.4156 0.0105 0.1947 0.1785 0.9973 0.4551 0.5100 0.5930 0.3710 0.7528 0.1250 0.6872 0.9421 0.9800 0.7033 0.6583 0.6218 0.4637 0.7270 0.6632 0.2751 0.6502 0.5870 0.9072 0.8614 0.9317 0.1854 0.8101 0.7092 0.9895 0.0510 0.3549 0.3283 0.0711 0.9594 0.2374 0.6143 0.2057 0.3140 0.0816 0.3204 0.7713 0.3255 0.6209 0.7792 0.9324 0.3146 0.5220 0.9987 0.7729 0.9734 0.1679 0.5899 0.5505 0.8534 0.4081 0.4399 0.3846 0.8307 0.6542 0.9678 0.9767 0.7743 0.7511 0.0047 0.1929 0.8578 0.3599 0.9773 0.5519 Column 10 0.0048 0.3635 0.1867 0.0294 0.4540 0.6682 0.0078 0.9814 0.0131 0.4543 A(:,:,7) = Columns 1 through 9 0.1220 0.9432 0.0327 0.1187 0.0702 0.6928 0.0028 0.4366 0.4037 0.3948 0.4153 0.3547 0.8249 0.8383 0.2257 0.9195 0.4899 0.7616 0.8732 0.5858 0.4214 0.2511 0.4170 0.4577 0.7082 0.8994 0.3408 0.3570 0.2134 0.4048 0.1521 0.7624 0.0923 0.3533 0.6187 0.6615 0.9541 0.7386 0.4097 0.6688 0.7723 0.1730 0.3951 0.3600 0.9785 0.1241 0.4366 0.8835 0.8958 0.9116 0.3115 0.9966 0.7366 0.8190 0.6790 0.0840 0.2282 0.5156 0.1454 0.6248 0.5041 0.1277 0.1117 0.0907 0.0432 0.9506 0.4369 0.3491 0.1131 0.8311 0.2404 0.3118 0.6920 0.6763 0.1430 0.9362 0.0794 0.2176 0.8230 0.8246 0.1108 0.7056 0.6133 0.2493 0.6552 0.8699 0.9480 0.2573 0.0453 0.0429 Column 10 0.6460 0.4443 0.3192 0.4721 0.6915 0.1756 0.9394 0.2663 0.3267 0.6161 A(:,:,8) = Columns 1 through 9 0.6530 0.1684 0.4773 0.8954 0.8781 0.8426 0.4832 0.3718 0.2459 0.0424 0.2651 0.6902 0.5609 0.7545 0.6006 0.4486 0.7061 0.5778 0.6399 0.9474 0.8572 0.4033 0.2456 0.2079 0.5027 0.5623 0.0053 0.3259 0.4649 0.8294 0.1364 0.7929 0.5986 0.0222 0.2313 0.4964 0.8472 0.0374 0.7879 0.0538 0.7992 0.1793 0.5796 0.8146 0.5350 0.5165 0.5578 0.0083 0.2534 0.2297 0.1661 0.9052 0.5205 0.5894 0.8990 0.9758 0.6812 0.6186 0.6784 0.6451 0.9062 0.0754 0.4854 0.4948 0.8909 0.7448 0.1534 0.9523 0.2047 0.6394 0.8116 0.1498 0.4070 0.8735 0.3647 0.4758 0.3328 0.1504 0.6474 0.5737 0.7496 0.8283 0.4821 0.0601 0.6839 0.8537 0.4692 0.0296 0.3838 0.8067 Column 10 0.9353 0.1426 0.6792 0.0381 0.7954 0.0841 0.6129 0.7192 0.3379 0.9196 A(:,:,9) = Columns 1 through 9 0.3699 0.8937 0.9017 0.3845 0.8810 0.0106 0.3515 0.4675 0.4820 0.2895 0.1265 0.7541 0.7019 0.2168 0.0094 0.4998 0.5131 0.0430 0.9216 0.7342 0.2387 0.2806 0.5031 0.1349 0.7534 0.9169 0.6383 0.6285 0.5271 0.7448 0.7918 0.6348 0.7523 0.8359 0.0195 0.8372 0.2025 0.9478 0.3208 0.0064 0.0199 0.1893 0.0714 0.9781 0.8056 0.2645 0.8349 0.0991 0.0094 0.8740 0.4383 0.7794 0.7992 0.2822 0.1885 0.4249 0.4717 0.2720 0.0302 0.8198 0.0354 0.4225 0.7946 0.7988 0.5795 0.2692 0.9670 0.0062 0.3625 0.1917 0.6909 0.8665 0.7872 0.9274 0.2627 0.2178 0.8572 0.1848 0.0821 0.3652 0.8671 0.7538 0.2327 0.5240 0.7970 0.6017 0.6531 0.2778 0.3107 0.1880 Column 10 0.0201 0.8990 0.4044 0.9143 0.7238 0.2955 0.9367 0.3599 0.4848 0.3133 A(:,:,10) = Columns 1 through 9 0.8694 0.5213 0.3046 0.9199 0.1449 0.2575 0.0329 0.3272 0.0015 0.6544 0.3181 0.2982 0.9403 0.2012 0.4181 0.7932 0.0545 0.6691 0.5217 0.0267 0.9461 0.5704 0.0898 0.9142 0.9679 0.5337 0.6669 0.8212 0.3489 0.9404 0.6735 0.2021 0.6974 0.9200 0.6777 0.9703 0.4507 0....

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