Cody

Solution 211933

Submitted on 3 Mar 2013 by andrea84
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.8092 0.0205 0.7519 0.3174 0.6312 0.1841 0.2238 0.6273 0.2751 0.9891 0.7486 0.9237 0.2287 0.8145 0.3551 0.7258 0.3736 0.0216 0.2486 0.0669 0.1202 0.6537 0.0642 0 0.9970 0.3704 0.0875 0.9106 0.4516 0.9394 0.5250 0.9326 0.7673 0.8523 0.2242 0.8416 0.6401 0.8006 0.2277 0.0182 0.3258 0.1635 0.6712 0.5056 0.6525 0.7342 0.1806 0.7458 0.8044 0.6838 0.5464 0.9211 0.7152 0.6357 0.6050 0.5710 0.0451 0.8131 0.9861 0.7837 0.3989 0.7947 0.6421 0.9509 0.3872 0.1769 0.7232 0.3833 0.0300 0.5341 0.4151 0.5774 0.4190 0.4440 0.1422 0.9574 0.3474 0.6173 0.5357 0.8854 0.1807 0.4400 0.3908 0.0600 0.0251 0.2653 0.6606 0.5755 0.0871 0.8990 0.2554 0.2576 0.8161 0.8667 0.4211 0.9246 0.3839 0.5301 0.8021 0.6259 a(:,:,2) = 0.1379 0 0.4116 0.3545 0.7829 0.2243 0.1079 0.3119 0.5013 0.7136 0.2178 0.6766 0.6026 0.9713 0.6938 0.2691 0.1822 0.1790 0.4317 0.6183 0.1821 0.9883 0.7505 0.3464 0.0098 0.6730 0.0991 0.3390 0.9976 0.3433 0.0418 0.7668 0.5835 0.8865 0.8432 0.4775 0.4898 0.2101 0.8116 0.9360 0.1069 0.3367 0.5518 0.4547 0.9223 0.6237 0.1932 0.5102 0.4857 0.1248 0.6164 0.6624 0.5836 0.4134 0.7710 0.2364 0.8959 0.9064 0.8944 0.7306 0.9397 0.2442 0.5118 0.2177 0.0427 0.1771 0.0991 0.6289 0.1375 0.6465 0.3545 0.2955 0.0826 0.1257 0.3782 0.8296 0.0442 0.1015 0.3900 0.8332 0.4106 0.6802 0.7196 0.3089 0.7043 0.7669 0.5573 0.3909 0.9274 0.3983 0.9843 0.5278 0.9962 0.7261 0.7295 0.9345 0.7725 0.0546 0.9175 0.7498 a(:,:,3) = 0.8352 0.4923 0.2815 0.7150 0.5038 0.5864 0.4035 0.9300 0.3037 0.2859 0.3225 0.6947 0.2304 0.8562 0.4896 0.6751 0.1220 0.3990 0.0462 0.5437 0.5523 0.9727 0.7111 0.2815 0.8770 0.3610 0.2684 0.0474 0.1955 0.9848 0.9791 0.3278 0.6246 0.7311 0.3531 0.6203 0.2578 0.3424 0.7202 0.7157 0.5493 0.8378 0.5906 0.1378 0.4494 0 0.3317 0.7360 0.7218 0.8390 0.3304 0.7391 0.6604 0.8367 0.9635 0.0193 0.1522 0.7947 0.8778 0.4333 0.6195 0.9542 0.0476 0.1386 0.0423 0.0839 0.3480 0.5449 0.5824 0.4706 0.3606 0.0319 0.3488 0.5882 0.9730 0.9748 0.1217 0.6862 0.0707 0.5607 0.7565 0.3569 0.4513 0.3662 0.1892 0.6513 0.8842 0.8936 0.9227 0.2691 0.4139 0.6627 0.2409 0.8068 0.6671 0.2312 0.0943 0.0548 0.8004 0.7490 a(:,:,4) = 0.5039 0.0216 0.9437 0.8295 0.4067 0.3889 0.4504 0.2753 0.5747 0.1170 0.6468 0.5598 0.5492 0.8491 0.6669 0.4547 0.2057 0.7167 0.3260 0.8147 0.3077 0.3008 0.7284 0.3725 0.9337 0.2467 0.8997 0.2834 0.4564 0.3249 0.1387 0.9394 0.5768 0.5932 0.8110 0.7844 0.7626 0.8962 0.7138 0.2462 0.4756 0.9809 0.0259 0.8726 0.4845 0.8828 0.8825 0.8266 0.8844 0.3427 0.3625 0.2866 0.4465 0.9335 0.7567 0.9137 0.2850 0.3900 0.7209 0.3757 0.7881 0.8008 0.6463 0.6685 0.4170 0.5583 0.6732 0.4979 0.0186 0.5466 0.7803 0.8961 0.5212 0.2068 0.9718 0.5989 0.6643 0.6948 0.6748 0.5619 0.6685 0.5975 0.3723 0.6539 0.9880 0.1489 0.1228 0.8344 0.4385 0.3958 0.1335 0.8840 0.9371 0.0721 0.8641 0.8997 0.4073 0.6096 0.4378 0.3981 a(:,:,5) = 0.5154 0.3242 0.9969 0.8266 0.5038 0.7202 0.3600 0.1093 0.6690 0.0196 0.6575 0.3017 0.5535 0.3945 0.6128 0.3469 0.4542 0.3899 0.5002 0.4352 0.9509 0.0117 0.5155 0.6135 0.8194 0.5170 0.3864 0.5909 0.2180 0.8322 0.7223 0.5399 0.3307 0.8186 0.5319 0.5567 0.7756 0.4594 0.5716 0.6174 0.4001 0.0954 0.4300 0.8862 0.2021 0.1565 0.7343 0.0503 0.1222 0.5201 0.8319 0.1465 0.4918 0.9311 0.4539 0.5621 0.4303 0.2287 0.6712 0.8639 0.1343 0.6311 0.0710 0.1908 0.4279 0.6948 0.6938 0.8342 0.5996 0.0977 0.0605 0.8593 0.8877 0.2586 0.9661 0.4265 0.9452 0.0156 0.0560 0.9081 0.0842 0.9742 0.0646 0.8979 0.6201 0.8363 0.7842 0.8637 0.0563 0.1080 0.1639 0.5708 0.4362 0.5934 0.6954 0.7314 0.7056 0.0781 0.1525 0.5170 a(:,:,6) = 0.1432 0.5078 0.9419 0.8669 0.1403 0.2436 0.1749 0.0684 0.7060 0.3180 0.5594 0.5856 0.6559 0.4068 0.2601 0.7851 0.1386 0.4363 0.6451 0.6086 0.0046 0.7629 0.4519 0.1126 0.0868 0.0741 0.5989 0.1739 0.5523 0.9102 0.7667 0.0830 0.8397 0.4438 0.4294 0.3939 0.9011 0.0261 0.2181 0.9091 0.8487 0.6616 0.5326 0.3002 0.2573 0.0034 0.9394 0.9547 0.7724 0.5916 0.9168 0.5170 0.5539 0.4014 0.2976 0.2207 0.2212 0.4306 0.2280 0.3326 0.9870 0.1710 0.6801 0.8334 0.4249 0.0013 0.4827 0.9616 0.3709 0.8531 0.5051 0.9386 0.3672 0.4036 0.1192 0.1892 0.3760 0.7624 0.8909 0.4424 0.2714 0.5905 0.2393 0.3902 0.4951 0.1425 0.5238 0.0073 0.8564 0.9044 0.1008 0.4406 0.5789 0.3604 0.7064 0.2681 0.2649 0.6800 0.4024 0.0332 a(:,:,7) = 0.5324 0.2748 0.1888 0.7624 0.6723 0.0249 0.7269 0.1930 0.0915 0.6423 0.7165 0.2415 0.0012 0.5761 0.4315 0.6714 0.3738 0.3416 0.6146 0.2213 0.1793 0.2431 0.3164 0.7477 0.6944 0.8372 0.5816 0.9329 0.0110 0.8371 0.3365 0.1542 0.6996 0.6455 0.2568 0.9715 0.1161 0.3907 0.5733 0.9711 0.1877 0.9564 0.6253 0.1232 0.0098 0.0569 0.0577 0.2732 0.7897 0.8464 0.3219 0.9357 0.5431 0.5044 0.5323 0.4503 0.9798 0.1519 0.2354 0.5060 0.4039 0.8187 0.4390 0.3473 0.2794 0.5825 0.2848 0.3971 0.4480 0.2789 0.5486 0.7283 0.2874 0.0921 0.9462 0.6866 0.5950 0.3747 0.5694 0.7466 0.0487 0.1758 0.5017 0.1478 0.9064 0.7194 0.9622 0.1311 0.0614 0.2369 0.5527 0.3604 0.7615 0.1982 0.3927 0.6500 0.1858 0.4350 0.4963 0.9573 a(:,:,8) = 0.6203 0.5761 0.5294 0.5246 0.8383 0.8266 0.9081 0.7117 0.7588 0.8090 0.6003 0.8106 0.8300 0.9727 0.5847 0.6769 0.5522 0.8715 0.9952 0.3565 0.1726 0.4038 0.8588 0.7104 0.9481 0.2076 0.0329 0.3287 0.1866 0.0732 0.0903 0.9884 0.7890 0.3119 0.0610 0.3181 0.0539 0.6501 0.7811 0.5910 0.2553 0.0900 0.3178 0.2915 0.5846 0.1338 0.8051 0.9748 0.1958 0.9102 0.8586 0.3209 0.4522 0.8504 0.2851 0.6715 0.4514 0.0760 0.9924 0.1938 0.9111 0.5114 0.7522 0.9116 0.8277 0.5710 0.3826 0.5870 0.8023 0.4324 0.6996 0.0606 0.1099 0.6393 0.1910 0.1698 0.7896 0.4139 0.4242 0.7492 0.7252 0.7257 0.1097 0.2554 0.4425 0.1477 0.3643 0.3091 0.7289 0.0392 0.2299 0.5566 0.2699 0.0887 0.3934 0.4761 0.5323 0.2638 0.4984 0.9463 a(:,:,9) = 0.7637 0.9350 0.9639 0.7124 0.1982 0.6153 0.9020 0.0930 0.0086 0.2411 0.5588 0.4795 0.1156 0.0167 0.1951 0.3766 0.7021 0.4635 0.7271 0.8414 0.1838 0.2318 0.0514 0.8009 0.3268 0.8772 0.3775 0.0093 0.3541 0.8572 0.4979 0.3963 0.3043 0.1425 0.8803 0.7849 0.7350 0.9150 0.7804 0.9636 0.5178 0.7051 0.5802 0.4785 0.4711 0.4650 0.9541 0.6427 0.4367 0.4889 0.9942 0.5586 0.5310 0.2568 0.4040 0.8140 0.5428 0.0014 0.4366 0.2203 0.8549 0.7566 0.9012 0.3691 0.1792 0.8984 0.5401 0.0304 0.0492 0.2262 0.9624 0.9955 0.5406 0.6618 0.9689 0.4292 0.3111 0.2085 0.0496 0.5368 0.6789 0.9624 0.4320 0.1696 0.4075 0.3343 0.0712 0.4550 0.0911 0.7621 0.4035 0.5351 0.5427 0.2788 0.8445 0.5966 0.1820 0.1273 0.5940 0.3476 a(:,:,10) = 0.4612 0.6333 0.1108 0.8569 0.1934 0.9508 0.8954 0.1439 0.0946 0.5230 0.6393 0.6240 0.4075 0.0434 0.7544 0.4976 0.5825 0.6060 0.3232 0.3253 0.9173 0.3279 0.8841 0.6916 0.3463 0.7551 0.5827 0.2545 0.7696 0.8318 0.1616 0.8030 0.5481 0.9790 0.4186 0.7424 0.8549 0.3242 0.2341 0.8103 0.7156 0.9995 0.3690 0.2833 0.1557 0.8311 0.0349 0.4018 0.7404 0.5570 0.5777 0.9810 0.2083 0.1338 0.8190 0.1565 0.8854 0.4064 0.6928 0.2630 0.4333 0.1270 0.4409 0.6853 0.6249 0.4573 0.4077 0.3862 0.8241 0.6806 0.8842 0.2322 0.9562 0.9095 0.7386 0.6181 0.0364 0.6098 0.8280 ...
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