Cody

Solution 187934

Submitted on 8 Jan 2013 by Tomasz
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.2455 0.4868 0.6982 0.9062 0.0682 0.7861 0.3098 0.1603 0.1190 0.7428 0.2375 0.3174 0.8586 0.3275 0.8048 0.6027 0.2471 0.7602 0.7119 0.1035 0.2736 0.1798 0.5426 0 0.6369 0.9941 0.1275 0.2528 0.3006 0.8096 0.8250 0.0841 0.7713 0.4795 0.9503 0.3968 0.0351 0.3385 0.3492 0.6026 0.8033 0.2506 0.5830 0.7352 0.2440 0.2890 0.6196 0.8730 0.2333 0.6404 0.7484 0.6366 0.9507 0.0151 0.1811 0.2983 0.7397 0.7585 0.6985 0.1020 0.8830 0.3800 0.7735 0.0706 0.2866 0.5638 0.1145 0.0614 0.7075 0.8493 0.9229 0.8356 0.7767 0.6977 0.8196 0.1090 0.6650 0.8165 0.5915 0.3673 0.8788 0.8914 0.2877 0.3386 0.2526 0.2577 0.0685 0.5861 0.9416 0.5573 0.3567 0.8149 0.4410 0.9897 0.5812 0.3287 0.8455 0.3099 0.1575 0.7699 A(:,:,2) = 0.4519 0 0.6298 0.6231 0.9031 0.6000 0.4997 0.0944 0.6693 0.8801 0.1478 0.7719 0.9575 0.4749 0.0145 0.2113 0.4272 0.3917 0.0105 0.5382 0.2727 0.2461 0.6955 0.6405 0.1908 0.3467 0.7903 0.0244 0.3745 0.8959 0.1534 0.1812 0.8859 0.8956 0.7105 0.8922 0.8519 0.3970 0.9933 0.9738 0.8065 0.5384 0.0842 0.3376 0.7639 0.6434 0.9943 0.5587 0.9081 0.2310 0.5501 0.8846 0.8413 0.0171 0.2028 0.9843 0.2842 0.4285 0.6031 0.1851 0.3333 0.7541 0.0255 0.0045 0.9318 0.5941 0.1164 0.3961 0.3484 0.3162 0.0704 0.9103 0.7243 0.4384 0.3970 0.7437 0.7741 0.6297 0.5133 0.0126 0.0481 0.1899 0.2788 0.7044 0.1528 0.9280 0.7287 0.5200 0.3452 0.7844 0.4469 0.1063 0.9470 0.2254 0.7017 0.9978 0.4771 0.7774 0.9254 0.3496 A(:,:,3) = 0.5855 0.8983 0.0361 0.3377 0.4129 0.9877 0.3056 0.2284 0.8426 0.5904 0.7447 0.6099 0.2739 0.9745 0.9018 0.1247 0.2198 0.4503 0.3562 0.2904 0.1587 0.5388 0.4913 0.1127 0.4499 0.7170 0.5908 0.1247 0.0187 0.5988 0.2558 0.0483 0.3113 0.5164 0.7486 0.0888 0.6359 0.6514 0.5391 0.6741 0.8557 0.5731 0.4215 0.8424 0.8277 0 0.7788 0.0103 0.2909 0.8197 0.1693 0.7691 0.9043 0.9963 0.8844 0.3881 0.0554 0.5544 0.9434 0.0268 0.8408 0.4808 0.6819 0.0103 0.3649 0.3825 0.8972 0.8814 0.3490 0.0841 0.7461 0.9007 0.6106 0.9721 0.3002 0.9898 0.1964 0.8074 0.8878 0.6861 0.4371 0.6332 0.8074 0.9599 0.8204 0.0248 0.8837 0.0641 0.2377 0.5048 0.4412 0.4830 0.9015 0.8128 0.1514 0.7374 0.3238 0.2801 0.9427 0.9772 A(:,:,4) = 0.9718 0.8054 0.8490 0.2977 0.3114 0.4061 0.4456 0.4261 0.3167 0.8039 0.7032 0.8200 0.7783 0.3784 0.0737 0.5770 0.6737 0.3596 0.0939 0.3408 0.0959 0.6208 0.0362 0.2280 0.6331 0.6094 0.4403 0.8683 0.6537 0.1431 0.0075 0.8850 0.1102 0.0461 0.8722 0.9153 0.3045 0.5419 0.5549 0.6188 0.1753 0.5886 0.6559 0.0621 0.3898 0.6479 0.7210 0.6877 0.6800 0.2163 0.5889 0.0129 0.3919 0.8766 0.1661 0.7094 0.3582 0.4422 0.2387 0.4398 0.3074 0.7451 0.5012 0.7362 0.9476 0.2466 0.8157 0.2640 0.9367 0.9506 0.0648 0.7971 0.5344 0.5394 0.4835 0.6753 0.8911 0.7321 0.7003 0.5778 0.9147 0.2047 0.5998 0.3623 0.2821 0.5643 0.7399 0.2023 0.4214 0.8535 0.0239 0.5576 0.0609 0.6183 0.8329 0.6828 0.0252 0.2377 0.0087 0.5114 A(:,:,5) = 0.4428 0.2045 0.9343 0.8028 0.3938 0.2390 0.7444 0.5258 0.6915 0.1926 0.1689 0.4044 0.1998 0.7582 0.1240 0.0308 0.5179 0.6437 0.4919 0.7600 0.6024 0.0639 0.2458 0.3215 0.1160 0.4725 0.4244 0.5633 0.7302 0.9630 0.0754 0.7829 0.3489 0.3859 0.6783 0.3041 0.7226 0.4678 0.1435 0.1994 0.7302 0.3116 0.5117 0.2821 0.3206 0.9411 0.2168 0.1943 0.2839 0.5298 0.1113 0.7023 0.8833 0.2651 0.4612 0.8024 0.2083 0.7758 0.0622 0.0197 0.4869 0.9151 0.0975 0.7536 0.4595 0.3677 0.6855 0.6411 0.6128 0.4345 0.3897 0.7037 0.9951 0.4348 0.6825 0.1172 0.9737 0.8096 0.2114 0.6106 0.8188 0.6241 0.9356 0.5190 0.7988 0.2443 0.4403 0.3622 0.1407 0.2164 0.5616 0.3255 0.2781 0.2844 0.2240 0.7671 0.8201 0.3077 0.2259 0.8720 A(:,:,6) = 0.8868 0.1312 0.3645 0.0129 0.2965 0.8068 0.4782 0.2108 0.1707 0.5066 0.4163 0.9850 0.5095 0.6124 0.9935 0.2418 0.6954 0.4942 0.9979 0.3415 0.7982 0.6245 0.6784 0.0585 0.3868 0.3487 0.1426 0.8034 0.3580 0.9073 0.2855 0.5831 0.3035 0.2419 0.7616 0.0219 0.5840 0.4762 0.5258 0.5184 0.9487 0.0992 0.8671 0.1110 0.8628 0.5406 0.9541 0.3865 0.0967 0.8289 0.1387 0.2652 0.5581 0.0278 0.5906 0.0837 0.8467 0.2844 0.7263 0.1971 0.3268 0.4961 0.7688 0.2205 0.3018 0.9553 0.9309 0.9640 0.7206 0.9726 0.2691 0.5074 0.6261 0.3290 0.3639 0.5942 0.3367 0.0590 0.6089 0.6502 0.6225 0.3890 0.6258 0.3233 0.3444 0.5385 0.4867 0.6749 0.3939 0.6825 0.7812 0.8430 0.0063 0.7325 0.0306 0.3725 0.1435 0.9908 0.1579 0.8800 A(:,:,7) = 0.1586 0.4412 0.5893 0.3639 0.8457 0.2121 0.1551 0.6213 0.8893 0.3663 0.5018 0.1715 0.6674 0.5011 0.5405 0.8987 0.4921 0.8984 0.3733 0.8163 0.8570 0.4074 0.8945 0.5123 0.0571 0.4502 0.8583 0.9070 0.8924 0.5199 0.1526 0.6260 0.0123 0.8801 0.6953 0.8179 0.2642 0.5153 0.8446 0.4017 0.1949 0.9682 0.4107 0.4680 0.4139 0.2149 0.9238 0.5167 0.6170 0.0277 0.2423 0.6370 0.1581 0.7053 0.1163 0.3607 0.0740 0.6695 0.8316 0.4827 0.4799 0.8687 0.9382 0.7447 0.9953 0.0974 0.8718 0.7739 0.8532 0.4016 0.8481 0.1351 0.8448 0.0711 0.4269 0.6495 0.3083 0.0300 0.1634 0.5146 0.8403 0.6413 0.4529 0.1866 0.7351 0.8325 0.6112 0.7494 0.1467 0.4494 0.3917 0.2160 0.8144 0.7255 0.7064 0.7406 0.6023 0.9014 0.3374 0.0533 A(:,:,8) = 0.4228 0.2442 0.7800 0.0331 0.3342 0.8495 0.5276 0.4779 0.8011 0.5674 0.1367 0.4065 0.0360 0.6749 0.1891 0.5526 0.3877 0.1596 0.6260 0.7523 0.0601 0.2639 0.5918 0.9193 0.3287 0.4961 0.7641 0.9306 0.4710 0.1256 0.3867 0.1257 0.0731 0.3888 0.2185 0.5577 0.1838 0.4402 0.5144 0.9481 0.0602 0.1115 0.5108 0.5289 0.2622 0.9854 0.7504 0.3080 0.6536 0.3712 0.4311 0.7691 0.6416 0.4403 0.9256 0.0137 0.1941 0.7412 0.8771 0.5837 0.6489 0.3867 0.5420 0.2569 0.8516 0.8662 0.6610 0.7114 0.8500 0.8425 0.3610 0.7870 0.3810 0.0028 0.7023 0.6590 0.9747 0.4575 0.2092 0.0100 0.6010 0.1620 0.1343 0.8297 0.7933 0.8158 0.4215 0.4178 0.7284 0.9040 0.0966 0.8892 0.4262 0.4386 0.2573 0.7692 0.9481 0.0214 0.9262 0.8985 A(:,:,9) = 0.6776 0.4302 0.0446 0.7636 0.3988 0.6402 0.1348 0.7696 0.9231 0.2796 0.9316 0.1808 0.2361 0.5593 0.9858 0.8826 0.2931 0.9072 0.3074 0.3946 0.1593 0.3971 0.6536 0.7826 0.2904 0.2452 0.4374 0.0816 0.8900 0.0636 0.1135 0.6641 0.6800 0.2615 0.4175 0.4025 0.7701 0.4469 0.9915 0.9538 0.7259 0.7281 0.0139 0.1571 0.9487 0.9804 0.9441 0.5466 0.1507 0.1433 0.3347 0.9223 0.5769 0.9254 0.6612 0.0411 0.4143 0.7459 0.5567 0.9065 0.1185 0.4163 0.5119 0.8099 0.8010 0.8841 0.1168 0.3876 0.8488 0.2791 0.5283 0.0797 0.4654 0.4462 0.5631 0.4909 0.6474 0.0434 0.9811 0.5301 0.1836 0.9102 0.6849 0.4782 0.6494 0.0553 0.8285 0.0467 0.1142 0.7796 0.6453 0.9152 0.6328 0.0556 0.8181 0.2323 0.7469 0.6626 0.1697 0.0571 A(:,:,10) = 0.8289 0.8143 0.7809 0.0233 0.4983 0.2189 0.1073 0.9592 0.7465 0.4858 0.5143 0.6938 0.0451 0.3298 0.9725 0.7215 0.1260 0.2858 0.2685 0.6005 0.3482 0.6871 0.2953 0.4620 0.1244 0.3598 0.8998 0.7589 0.2834 0.7188 0.9431 0.5505 0.8948 0.7597 0.4998 0.3896 0.8824 0.9081 0.4021 0.2861 0.4905 0.8616 0.0366 0.1828 0.2920 0.5930 0.7636 0.2914 0.4976 0.9098 0.2279 0.3332 0.9479 0.8538 0.6388 0.2356 0.4326 0.6294 0.0408 0.8798 0.2541 0.9421 0.1687 0.9122 0.8504 0.3171 0.5255 0.0651 0.6304 0.6425 0.9365 0.5466 0.4981 0.1273 0.3577 0.4197 0.7779 0.0301 0.6731 ...
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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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 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