Cody

Solution 173203

Submitted on 5 Dec 2012 by Azim
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.3824 0.8853 0.5596 0.4321 0.0334 0.3105 0.1597 0.2819 0.4411 0.0028 0.9636 0.9169 0.5154 0.7662 0.7095 0.6150 0.4646 0.3023 0.6729 0.8272 0.7071 0.1247 0.2308 0 0.0865 0.8408 0.8760 0.1043 0.2087 0.3600 0.4092 0.1615 0.6283 0.7583 0.4558 0.0077 0.4670 0.6835 0.9509 0.4655 0.3635 0.3618 0.8079 0.8493 0.8685 0.5348 0.6410 0.4622 0.6974 0.3834 0.4545 0.0808 0.9402 0.4168 0.1249 0.8875 0.0357 0.8660 0.3537 0.4662 0.6520 0.5619 0.4809 0.1497 0.6803 0.9680 0.1687 0.7785 0.2199 0.3907 0.7903 0.2966 0.4460 0.2111 0.1116 0.7507 0.1559 0.1611 0.8005 0.6719 0.7192 0.5216 0.9835 0.7738 0.1375 0.9567 0.9600 0.2750 0.7480 0.8807 0.2544 0.7213 0.1065 0.9108 0.0197 0.2286 0.4068 0.3659 0.0963 0.7731 A(:,:,2) = 0.4182 0 0.9183 0.8651 0.3863 0.6430 0.6352 0.1496 0.9209 0.3084 0.2642 0.7254 0.6401 0.9679 0.5371 0.9447 0.6270 0.3039 0.0554 0.6551 0.4756 0.8766 0.0107 0.9260 0.8758 0.1935 0.4090 0.1634 0.7559 0.9649 0.9367 0.7425 0.8248 0.2338 0.7583 0.2759 0.5281 0.6019 0.5409 0.3678 0.1451 0.8804 0.4785 0.8337 0.6545 0.0309 0.0081 0.7313 0.1312 0.5071 0.6181 0.1833 0.0021 0.7298 0.4661 0.6019 0.5443 0.7560 0.0123 0.5308 0.1198 0.6605 0.1024 0.2646 0.1934 0.1287 0.7384 0.8949 0.6040 0.9819 0.9112 0.9604 0.8151 0.4226 0.4810 0.5964 0.2152 0.1204 0.5587 0.1927 0.2348 0.8189 0.8872 0.6403 0.3016 0.9117 0.2965 0.0646 0.4922 0.5835 0.8986 0.2901 0.7225 0.4111 0.6013 0.5201 0.7380 0.5238 0.4874 0.1887 A(:,:,3) = 0.2181 0.1945 0.2834 0.9296 0.0774 0.3001 0.5878 0.8110 0.6308 0.8306 0.0178 0.0538 0.8673 0.2078 0.4691 0.0461 0.2076 0.2151 0.0476 0.9884 0.7077 0.6164 0.0199 0.8921 0.6129 0.4075 0.0016 0.7739 0.8889 0.7732 0.4362 0.4641 0.4373 0.4950 0.7228 0.8377 0.1918 0.1926 0.5776 0.3879 0.9792 0.6624 0.4478 0.6887 0.8842 0 0.4601 0.2198 0.7302 0.8351 0.9559 0.9855 0.4238 0.1249 0.3596 0.2461 0.1726 0.7854 0.2537 0.8849 0.6417 0.3991 0.0975 0.8093 0.8323 0.9627 0.2840 0.8633 0.7852 0.3445 0.3778 0.5562 0.4057 0.7796 0.6646 0.5088 0.2839 0.6963 0.5367 0.2364 0.1745 0.4994 0.9777 0.3907 0.7055 0.0745 0.8312 0.1693 0.1430 0.5069 0.0596 0.4484 0.4090 0.3247 0.5572 0.5075 0.7876 0.8201 0.9777 0.6622 A(:,:,4) = 0.1824 0.0328 0.4421 0.6560 0.5630 0.7044 0.3224 0.0463 0.7086 0.6037 0.9615 0.0554 0.1410 0.4430 0.0892 0.2802 0.7595 0.3309 0.1969 0.1006 0.1408 0.1358 0.0011 0.0150 0.6247 0.2417 0.9249 0.0124 0.7066 0.7144 0.4004 0.3527 0.3636 0.2429 0.7322 0.4075 0.1810 0.7972 0.4493 0.0656 0.8260 0.7904 0.1322 0.8753 0.0070 0.3773 0.6046 0.2652 0.2392 0.9249 0.0098 0.2766 0.0860 0.7363 0.5106 0.0717 0.3361 0.1799 0.3605 0.7376 0.2723 0.9420 0.0219 0.8361 0.1589 0.4751 0.0724 0.2638 0.3643 0.7937 0.2920 0.9810 0.1098 0.0644 0.3016 0.1698 0.7772 0.6689 0.2949 0.7961 0.3323 0.3846 0.6703 0.8429 0.9689 0.6119 0.4250 0.8783 0.7827 0.0670 0.1266 0.1587 0.1532 0.5215 0.9552 0.3505 0.0636 0.0010 0.8694 0.3622 A(:,:,5) = 0.8329 0.5037 0.9474 0.3367 0.3080 0.6237 0.1171 0.7845 0.0583 0.0282 0.5080 0.8913 0.8627 0.8807 0.3216 0.8433 0.6434 0.3999 0.3293 0.8439 0.4419 0.7757 0.1629 0.9858 0.9603 0.5927 0.5840 0.4643 0.0498 0.3222 0.1693 0.0942 0.5858 0.8146 0.5760 0.6341 0.0989 0.1597 0.1236 0.2186 0.7987 0.3381 0.4717 0.1126 0.7424 0.2946 0.0070 0.7654 0.1920 0.7522 0.0490 0.4742 0.1362 0.9392 0.2801 0.8054 0.4832 0.3336 0.3080 0.2643 0.0648 0.1014 0.3855 0.7556 0.7572 0.3264 0.6429 0.7534 0.8039 0.4804 0.1177 0.9565 0.6884 0.7554 0.6240 0.9068 0.6690 0.2346 0.5420 0.3581 0.4124 0.3921 0.1883 0.8883 0.5815 0.3107 0.4747 0.8163 0.1708 0.7970 0.0286 0.3993 0.6366 0.5334 0.1347 0.6258 0.0477 0.7583 0.0793 0.2833 A(:,:,6) = 0.6655 0.8793 0.3156 0.4563 0.8497 0.6519 0.3683 0.5088 0.0466 0.4819 0.0670 0.5614 0.5570 0.5644 0.4734 0.5853 0.8235 0.7780 0.5172 0.7059 0.7863 0.1527 0.7355 0.2424 0.1311 0.2865 0.3651 0.4671 0.3761 0.2819 0.3057 0.6345 0.0689 0.1297 0.6174 0.7816 0.9923 0.8016 0.3695 0.2080 0.0035 0.6977 0.4126 0.0674 0.8629 0.6989 0.5843 0.4542 0.4169 0.3551 0.9925 0.9080 0.5165 0.0877 0.7813 0.1591 0.1102 0.7548 0.6638 0.6201 0.1045 0.5044 0.4431 0.1192 0.9705 0.8551 0.0266 0.5225 0.8554 0.7551 0.5680 0.7575 0.7683 0.9841 0.1383 0.2057 0.3137 0.1253 0.8078 0.6740 0.3332 0.5014 0.8742 0.4836 0.3327 0.7707 0.6254 0.0628 0.9823 0.4124 0.5660 0.6193 0.9605 0.0564 0.8302 0.7667 0.1467 0.8924 0.0134 0.4013 A(:,:,7) = 0.2340 0.7859 0.2432 0.6408 0.6381 0.9325 0.8269 0.7139 0.5416 0.0021 0.7002 0.7574 0.9483 0.9592 0.4538 0.7616 0.8631 0.6005 0.1643 0.9883 0.6880 0.9290 0.9081 0.1188 0.4610 0.5181 0.7181 0.4106 0.3140 0.9006 0.4955 0.0681 0.6662 0.9066 0.1780 0.9570 0.2595 0.6283 0.9815 0.7742 0.1415 0.0585 0.3234 0.1273 0.0063 0.2738 0.1996 0.7329 0.8583 0.8717 0.5741 0.6510 0.1084 0.3215 0.8388 0.2486 0.6360 0.5435 0.6515 0.3168 0.0577 0.5014 0.4157 0.5796 0.3640 0.6031 0.9998 0.1207 0.6654 0.4646 0.8796 0.3689 0.8024 0.1779 0.9381 0.9948 0.3191 0.7966 0.3894 0.5810 0.9931 0.4006 0.4195 0.2850 0.1813 0.6369 0.0495 0.4406 0.2447 0.0557 0.4618 0.4620 0.7795 0.0692 0.6764 0.7367 0.0696 0.9959 0.4961 0.3885 A(:,:,8) = 0.2119 0.9270 0.8390 0.2180 0.4308 0.0453 0.5476 0.6644 0.1305 0.8404 0.1547 0.4771 0.3061 0.2547 0.3037 0.0074 0.9085 0.0475 0.7946 0.0410 0.5497 0.2246 0.0468 0.4122 0.4555 0.2111 0.5551 0.2719 0.7784 0.7088 0.4206 0.8296 0.0130 0.1978 0.9634 0.3779 0.9498 0.4505 0.0463 0.8399 0.2918 0.5470 0.4155 0.8368 0.1657 0.4759 0.5740 0.3162 0.2872 0.6045 0.0437 0.9364 0.6266 0.3492 0.1138 0.7769 0.1722 0.2262 0.4893 0.7395 0.2771 0.3663 0.2628 0.0633 0.2636 0.1231 0.5053 0.6510 0.2545 0.6366 0.6644 0.9207 0.9042 0.3186 0.7451 0.4077 0.6243 0.7615 0.2156 0.1599 0.0626 0.7889 0.4887 0.0205 0.0444 0.1955 0.3979 0.6637 0.7218 0.1946 0.7587 0.2721 0.2729 0.2160 0.8638 0.3509 0.3487 0.4122 0.4348 0.2071 A(:,:,9) = 0.5505 0.0930 0.6230 0.9831 0.7254 0.9295 0.9439 0.5489 0.9657 0.7932 0.7068 0.0363 0.2095 0.3618 0.3890 0.7694 0.0774 0.6895 0.1982 0.9279 0.8153 0.6767 0.8842 0.7014 0.6853 0.2110 0.0315 0.8133 0.4238 0.9920 0.3112 0.6030 0.3235 0.4105 0.9545 0.5123 0.0071 0.4778 0.4495 0.9980 0.5110 0.5974 0.5742 0.9179 0.5536 0.3194 0.3424 0.3665 0.4297 0.6263 0.3857 0.9362 0.9672 0.4670 0.8176 0.9223 0.1624 0.3253 0.9926 0.3802 0.2547 0.8994 0.2849 0.9336 0.5542 0.0425 0.9150 0.2014 0.2108 0.0750 0.0792 0.0395 0.0211 0.0460 0.2660 0.1057 0.1704 0.7436 0.2613 0.5309 0.2382 0.0815 0.0718 0.3633 0.1579 0.6321 0.0418 0.1780 0.8086 0.6466 0.8223 0.2977 0.1284 0.7627 0.1447 0.8861 0.9881 0.0048 0.8900 0.0799 A(:,:,10) = 0.0935 0.6709 0.5735 0.5421 0.7202 0.0528 0.3704 0.3021 0.4819 0.7382 0.4914 0.6134 0.7693 0.0017 0.5815 0.5221 0.7414 0.4163 0.6650 0.9852 0.8048 0.5687 0.7422 0.7152 0.7400 0.2034 0.5673 0.4823 0.4548 0.3204 0.1694 0.6609 0.4405 0.0936 0.7780 0.9028 0.8803 0.4872 0.6483 0.0649 0.4712 0.6988 0.0928 0.9296 0.0952 0.6324 0.9257 0.5907 0.9839 0.5733 0.4007 0.9961 0.3887 0.8398 0.1309 0.4621 0.4747 0.1579 0.8838 0.3207 0.8976 0.0625 0.0966 0.7786 0.6737 0.6679 0.1507 0.3957 0.8230 0.3250 0.1462 0.9513 0.1463 0.9573 0.7649 0.8487 0.9078 0.1070 0.4213 ...
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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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 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