Cody

Solution 232350

Submitted on 18 Apr 2013 by hari laxman
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.5895 0.7302 0.4253 0.6385 0.5313 0.4401 0.2891 0.6753 0.3225 0.1917 0.2262 0.3439 0.3127 0.0336 0.3251 0.5271 0.6718 0.0067 0.7847 0.7384 0.3846 0.5841 0.1615 0 0.1056 0.4574 0.6951 0.6022 0.4714 0.2428 0.5830 0.1078 0.1788 0.3196 0.6110 0.8754 0.0680 0.3868 0.0358 0.9174 0.2518 0.9063 0.4229 0.5309 0.7788 0.5181 0.2548 0.9160 0.1759 0.2691 0.2904 0.8797 0.0942 0.6544 0.4235 0.9436 0.2240 0.0012 0.7218 0.7655 0.6171 0.8178 0.5985 0.4076 0.0908 0.6377 0.6678 0.4624 0.4735 0.1887 0.2653 0.2607 0.4709 0.8200 0.2665 0.9577 0.8444 0.4243 0.1527 0.2875 0.8244 0.5944 0.6959 0.7184 0.1537 0.2407 0.3445 0.4609 0.3411 0.0911 0.9827 0.0225 0.6999 0.9686 0.2810 0.6761 0.7805 0.7702 0.6074 0.5762 A(:,:,2) = 0.6834 0 0.8419 0.9398 0.2187 0.9329 0.3935 0.2428 0.3309 0.8085 0.5466 0.1194 0.8329 0.6456 0.1058 0.9727 0.6714 0.4424 0.4243 0.7551 0.4257 0.6073 0.2564 0.4795 0.1097 0.1920 0.7413 0.6878 0.2703 0.3774 0.6444 0.4501 0.6135 0.6393 0.0636 0.1389 0.5201 0.3592 0.1971 0.2160 0.6476 0.4587 0.5822 0.5447 0.4046 0.6963 0.3477 0.7363 0.8217 0.7904 0.6790 0.6619 0.5407 0.6473 0.4484 0.0938 0.1500 0.3947 0.4299 0.9493 0.6358 0.7703 0.8699 0.5439 0.3658 0.5254 0.5861 0.6834 0.8878 0.3276 0.9452 0.3502 0.2648 0.7210 0.7635 0.5303 0.2621 0.7040 0.3912 0.6713 0.2089 0.6620 0.3181 0.5225 0.6279 0.8611 0.0445 0.4423 0.7691 0.4386 0.7093 0.4162 0.1192 0.9937 0.7720 0.4849 0.7549 0.0196 0.3968 0.8335 A(:,:,3) = 0.7689 0.7487 0.1897 0.8790 0.4981 0.6609 0.8627 0.4896 0.6952 0.5650 0.1673 0.8256 0.4950 0.9889 0.9009 0.7298 0.4843 0.1925 0.4991 0.6403 0.8620 0.7900 0.1476 0.0005 0.5747 0.8908 0.8449 0.1231 0.5358 0.4170 0.9899 0.3185 0.0550 0.8654 0.8452 0.9823 0.2094 0.2055 0.4452 0.2060 0.5144 0.5341 0.8507 0.6126 0.7386 0 0.5523 0.1465 0.1239 0.9479 0.8843 0.0900 0.5606 0.9900 0.5860 0.5814 0.6299 0.1891 0.4904 0.0821 0.5880 0.1117 0.9296 0.5277 0.2467 0.9283 0.0320 0.0427 0.8530 0.1057 0.1548 0.1363 0.6967 0.4795 0.6664 0.5801 0.6147 0.6352 0.8739 0.1420 0.1999 0.6787 0.5828 0.8013 0.0835 0.0170 0.3624 0.2819 0.2703 0.1665 0.4070 0.4952 0.8154 0.2278 0.6260 0.1209 0.0495 0.5386 0.2085 0.6210 A(:,:,4) = 0.5737 0.7856 0.4671 0.6628 0.4648 0.2089 0.5972 0.8972 0.2982 0.1092 0.0521 0.5134 0.6482 0.3308 0.7640 0.9052 0.2999 0.1967 0.0464 0.8258 0.9312 0.1776 0.0252 0.8985 0.8182 0.6754 0.1341 0.0934 0.5054 0.3381 0.7287 0.3986 0.8422 0.1182 0.1002 0.4685 0.2126 0.3074 0.7614 0.2940 0.7378 0.1339 0.5590 0.9884 0.1781 0.9121 0.8949 0.4561 0.6311 0.7463 0.0634 0.0309 0.8541 0.5400 0.3596 0.1040 0.0715 0.1017 0.0899 0.0103 0.8604 0.9391 0.3479 0.7069 0.0567 0.7455 0.2425 0.9954 0.0809 0.0484 0.9344 0.3013 0.4460 0.9995 0.5219 0.7363 0.0538 0.3321 0.7772 0.6679 0.9844 0.2955 0.0542 0.2878 0.3358 0.5619 0.4417 0.2973 0.9051 0.6035 0.8589 0.3329 0.1771 0.4145 0.1757 0.1842 0.0133 0.0620 0.5338 0.5261 A(:,:,5) = 0.7297 0.6079 0.0729 0.3288 0.3664 0.3883 0.5309 0.6948 0.7690 0.7727 0.7073 0.7413 0.0885 0.6538 0.3692 0.5518 0.0915 0.7581 0.3960 0.6964 0.7814 0.1048 0.7984 0.7491 0.6850 0.2290 0.4053 0.4326 0.2729 0.1253 0.2880 0.1279 0.9430 0.5832 0.5979 0.6419 0.1048 0.6555 0.0372 0.1302 0.6925 0.5495 0.6837 0.7400 0.7894 0.4845 0.1123 0.1098 0.6733 0.0924 0.5567 0.4852 0.1321 0.2348 0.3677 0.1518 0.7844 0.9338 0.4296 0.0078 0.3965 0.8905 0.7227 0.7350 0.2060 0.7819 0.2916 0.1875 0.4517 0.4231 0.0616 0.7990 0.1104 0.9706 0.0867 0.1006 0.6035 0.2662 0.6099 0.6556 0.7802 0.7343 0.1175 0.8669 0.7719 0.2941 0.9644 0.7978 0.0594 0.7229 0.3376 0.0513 0.6407 0.0862 0.2057 0.2374 0.4325 0.4876 0.3158 0.5312 A(:,:,6) = 0.1088 0.2176 0.5578 0.4024 0.6855 0.5583 0.9357 0.2122 0.9535 0.3989 0.6318 0.2510 0.3134 0.9828 0.2941 0.7425 0.4579 0.0985 0.5409 0.4151 0.1265 0.8929 0.1662 0.4022 0.5306 0.4243 0.2405 0.8236 0.6797 0.1807 0.1343 0.7032 0.6225 0.6207 0.8324 0.4294 0.7639 0.1750 0.0366 0.2554 0.0986 0.5557 0.9879 0.1544 0.5975 0.1249 0.7593 0.1636 0.8092 0.0205 0.1420 0.1844 0.1704 0.3813 0.3353 0.0244 0.7406 0.6660 0.7486 0.9237 0.1683 0.2120 0.2578 0.1611 0.2992 0.2902 0.7437 0.8944 0.1202 0.6537 0.1962 0.0773 0.3968 0.7581 0.4526 0.3175 0.1059 0.5166 0.5250 0.9326 0.3175 0.9138 0.0740 0.8711 0.4226 0.6537 0.6816 0.7027 0.3258 0.1635 0.3164 0.7067 0.6841 0.3508 0.3596 0.9569 0.4633 0.1536 0.5464 0.9211 A(:,:,7) = 0.7947 0.6421 0.9509 0.3872 0.1769 0.7232 0.3833 0.0300 0.5341 0.9397 0.5774 0.4190 0.4440 0.1422 0.9574 0.3474 0.6173 0.5357 0.8854 0.3545 0.4400 0.3908 0.0600 0.0251 0.2653 0.6606 0.5755 0.0871 0.8990 0.4106 0.2576 0.8161 0.8667 0.4211 0.9246 0.3839 0.5301 0.8021 0.6259 0.9843 0.7519 0.3174 0.6312 0.1841 0.2238 0.6273 0.2751 0.9891 0.1379 0.9456 0.2287 0.8145 0.3551 0.7258 0.3736 0.0216 0.2486 0.0669 0.2178 0.6766 0.0642 0.7891 0.9970 0.3704 0.0875 0.9106 0.4516 0.9394 0.1821 0.9883 0.7673 0.8523 0.2242 0.8416 0.6401 0.8006 0.2277 0.0182 0.0418 0.7668 0.6712 0.5056 0.6525 0.7342 0.1806 0.7458 0.8044 0.6838 0.1069 0.3367 0.7152 0.6357 0.6050 0.5710 0.0451 0.8131 0.9861 0.7837 0.6164 0.6624 A(:,:,8) = 0.2442 0.5118 0.2177 0.0427 0.1771 0.0991 0.6289 0.1375 0.6465 0.6195 0.2955 0.0826 0.1257 0.3782 0.8296 0.0442 0.1015 0.3900 0.8332 0.3606 0.6802 0.7196 0.3089 0.7043 0.7669 0.5573 0.3909 0.9274 0.3983 0.7565 0.5278 0.9962 0.7261 0.7295 0.9345 0.7725 0.0546 0.9175 0.7498 0.4139 0.4116 0.3545 0.7829 0.2243 0.1079 0.3119 0.5013 0.7136 0.8352 0.4923 0.6026 0.9713 0.6938 0.2691 0.1822 0.1790 0.4317 0.6183 0.3225 0.6947 0.7505 0.3464 0.0098 0.6730 0.0991 0.3390 0.9976 0.3433 0.5523 0.9727 0.5835 0.8865 0.8432 0.4775 0.4898 0.2101 0.8116 0.9360 0.9791 0.3278 0.5518 0.4547 0.9223 0.6237 0.1932 0.5102 0.4857 0.1248 0.5493 0.8378 0.5836 0.4134 0.7710 0.2364 0.8959 0.9064 0.8944 0.7306 0.3304 0.7391 A(:,:,9) = 0.9542 0.0476 0.1386 0.0423 0.0839 0.3480 0.5449 0.5824 0.4706 0.7881 0.0319 0.3488 0.5882 0.9730 0.9748 0.1217 0.6862 0.0707 0.5607 0.7803 0.3569 0.4513 0.3662 0.1892 0.6513 0.8842 0.8936 0.9227 0.2691 0.6685 0.6627 0.2409 0.8068 0.6671 0.2312 0.0943 0.0548 0.8004 0.7490 0.1335 0.2815 0.7150 0.5038 0.5864 0.4035 0.9300 0.3037 0.2859 0.5039 0.0216 0.2304 0.8562 0.4896 0.6751 0.1220 0.3990 0.0462 0.5437 0.6468 0.5598 0.7111 0.2815 0.8770 0.3610 0.2684 0.0474 0.1955 0.9848 0.3077 0.3008 0.6246 0.7311 0.3531 0.6203 0.2578 0.3424 0.7202 0.7157 0.1387 0.9394 0.5906 0.1378 0.4494 0.8112 0.3317 0.7360 0.7218 0.8390 0.4756 0.9809 0.6604 0.8367 0.9635 0.0193 0.1522 0.7947 0.8778 0.4333 0.3625 0.2866 A(:,:,10) = 0.8008 0.6463 0.6685 0.4170 0.5583 0.6732 0.4979 0.0186 0.5466 0.1343 0.8961 0.5212 0.2068 0.9718 0.5989 0.6643 0.6948 0.6748 0.5619 0.0605 0.5975 0.3723 0.6539 0.9880 0.1489 0.1228 0.8344 0.4385 0.3958 0.0842 0.8840 0.9371 0.0721 0.8641 0.8997 0.4073 0.6096 0.4378 0.3981 0.1639 0.9437 0.8295 0.4067 0.3889 0.4504 0.2753 0.5747 0.1170 0.5154 0.3242 0.5492 0.8491 0.6669 0.4547 0.2057 0.7167 0.3260 0.8147 0.6575 0.3017 0.7284 0.3725 0.9337 0.2467 0.8997 0.2834 0.4564 0.3249 0.9509 0.0117 0.5768 0.5932 0.8110 0.7844 0.7626 0.8962 0.7138 0.2462 0.7223 ...
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