Cody

Solution 186774

Submitted on 6 Jan 2013 by the cyclist
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.4314 0.8530 0.4173 0.7803 0.2348 0.5470 0.9294 0.6443 0.2077 0.3111 0.9106 0.6221 0.0497 0.3897 0.3532 0.2963 0.7757 0.3786 0.3012 0.9234 0.1818 0.3510 0.9027 0 0.8212 0.7447 0.4868 0.8116 0.4709 0.4302 0.2638 0.5132 0.9448 0.4039 0.0154 0.1890 0.4359 0.5328 0.2305 0.1848 0.1455 0.4018 0.4909 0.0965 0.0430 0.6868 0.4468 0.3507 0.8443 0.9049 0.1361 0.0760 0.4893 0.1320 0.1690 0.1835 0.3063 0.9390 0.1948 0.9797 0.8693 0.2399 0.3377 0.9421 0.6491 0.3685 0.5085 0.8759 0.2259 0.4389 0.5797 0.1233 0.9001 0.9561 0.7317 0.6256 0.5108 0.5502 0.1707 0.1111 0.5499 0.1839 0.3692 0.5752 0.6477 0.7802 0.8176 0.6225 0.2277 0.2581 0.1450 0.2400 0.1112 0.0598 0.4509 0.0811 0.7948 0.5870 0.4357 0.4087 A(:,:,2) = 0.5949 0 0.9631 0.0377 0.1068 0.0305 0.1829 0.0596 0.6596 0.1734 0.2622 0.2625 0.5468 0.8852 0.6538 0.7441 0.2399 0.6820 0.5186 0.3909 0.6028 0.8010 0.5211 0.9133 0.4942 0.5000 0.8865 0.0424 0.9730 0.8314 0.7112 0.0292 0.2316 0.7962 0.7791 0.4799 0.0287 0.0714 0.6490 0.8034 0.2217 0.9289 0.4889 0.0987 0.7150 0.9047 0.4899 0.5216 0.8003 0.0605 0.1174 0.7303 0.6241 0.2619 0.9037 0.6099 0.1679 0.0967 0.4538 0.3993 0.2967 0.4886 0.6791 0.3354 0.8909 0.6177 0.9787 0.8181 0.4324 0.5269 0.3188 0.5785 0.3955 0.6797 0.3342 0.8594 0.7127 0.8175 0.8253 0.4168 0.4242 0.2373 0.3674 0.1366 0.6987 0.8055 0.5005 0.7224 0.0835 0.6569 0.5079 0.4588 0.9880 0.7212 0.1978 0.5767 0.4711 0.1499 0.1332 0.6280 A(:,:,3) = 0.2920 0.9516 0.3015 0.0326 0.6448 0.2518 0.9063 0.4229 0.5309 0.7788 0.4317 0.9203 0.7011 0.5612 0.3763 0.2904 0.8797 0.0942 0.6544 0.4235 0.0155 0.0527 0.6663 0.8819 0.1909 0.6171 0.8178 0.5985 0.4076 0.0908 0.9841 0.7379 0.5391 0.6692 0.4283 0.2653 0.2607 0.4709 0.8200 0.2665 0.1672 0.2691 0.6981 0.1904 0.4820 0 0.5944 0.6959 0.7184 0.1537 0.1062 0.4228 0.6665 0.3689 0.1206 0.9827 0.0225 0.6999 0.9686 0.2810 0.3724 0.5479 0.1781 0.4607 0.5895 0.7302 0.4253 0.6385 0.5313 0.4401 0.1981 0.9427 0.1280 0.9816 0.2262 0.3439 0.3127 0.0336 0.3251 0.5271 0.4897 0.4177 0.9991 0.1564 0.3846 0.5841 0.1615 0.0688 0.1056 0.4574 0.3395 0.9831 0.1711 0.8555 0.5830 0.1078 0.1788 0.3196 0.6110 0.8754 A(:,:,4) = 0.5181 0.2548 0.9160 0.1759 0.2691 0.6476 0.4587 0.5822 0.5447 0.4046 0.9436 0.2240 0.0012 0.7218 0.7655 0.6790 0.6619 0.5407 0.6473 0.4484 0.6377 0.6678 0.4624 0.4735 0.1887 0.6358 0.7703 0.8699 0.5439 0.3658 0.9577 0.8444 0.4243 0.1527 0.2875 0.9452 0.3502 0.2648 0.7210 0.7635 0.2407 0.3445 0.4609 0.3411 0.0911 0.2089 0.6620 0.3181 0.5225 0.6279 0.6761 0.7805 0.7702 0.6074 0.5762 0.7093 0.4162 0.1192 0.9937 0.7720 0.2891 0.6753 0.3225 0.1917 0.6834 0.2362 0.8419 0.9398 0.2187 0.9329 0.6718 0.0067 0.7847 0.7384 0.5466 0.1194 0.8329 0.6456 0.1058 0.9727 0.6951 0.6022 0.4714 0.2428 0.4257 0.6073 0.2564 0.4795 0.1097 0.1920 0.0680 0.3868 0.0358 0.9174 0.6444 0.4501 0.6135 0.6393 0.0636 0.1389 A(:,:,5) = 0.6963 0.3477 0.7363 0.8217 0.7904 0.5144 0.5341 0.8507 0.6126 0.7386 0.0938 0.1500 0.3947 0.4299 0.9493 0.8843 0.0900 0.5606 0.9900 0.5860 0.5254 0.5861 0.6834 0.8878 0.3276 0.5880 0.1117 0.9296 0.5277 0.2467 0.5303 0.2621 0.7040 0.3912 0.6713 0.1548 0.1363 0.6967 0.4795 0.6664 0.8611 0.0445 0.4423 0.7691 0.4386 0.1999 0.6787 0.5828 0.8013 0.0835 0.4849 0.7549 0.0196 0.3968 0.8335 0.4070 0.4952 0.8154 0.2278 0.6260 0.3935 0.2428 0.3309 0.8085 0.7689 0.7487 0.1897 0.8790 0.4981 0.6609 0.6714 0.4424 0.4243 0.7551 0.1673 0.8256 0.4950 0.9889 0.9009 0.7298 0.7413 0.6878 0.2703 0.3774 0.8620 0.7900 0.1476 0.0005 0.5747 0.8908 0.5201 0.3592 0.1971 0.2160 0.9899 0.3185 0.0550 0.8654 0.8452 0.9823 A(:,:,6) = 0.7690 0.5523 0.1465 0.1239 0.9479 0.7378 0.1339 0.5590 0.9884 0.1781 0.5814 0.6299 0.1891 0.4904 0.0821 0.0634 0.0309 0.8541 0.5400 0.3596 0.9283 0.0320 0.0427 0.8530 0.1057 0.8604 0.9391 0.3479 0.7069 0.0567 0.5801 0.6147 0.6352 0.8739 0.1420 0.9344 0.3013 0.4460 0.9995 0.5219 0.0170 0.3624 0.2819 0.2703 0.1665 0.9844 0.2955 0.0542 0.2878 0.3358 0.1209 0.0495 0.5386 0.2085 0.6210 0.8589 0.3329 0.1771 0.4145 0.1757 0.8627 0.4896 0.6952 0.5650 0.5737 0.7856 0.4671 0.6628 0.4648 0.2089 0.4843 0.1925 0.4991 0.6403 0.0521 0.5134 0.6482 0.3308 0.7640 0.9052 0.8449 0.1231 0.5358 0.4170 0.9312 0.1776 0.0252 0.8985 0.8182 0.6754 0.2094 0.2055 0.4452 0.2060 0.7287 0.3986 0.8422 0.1182 0.1002 0.4685 A(:,:,7) = 0.9121 0.8949 0.4561 0.6311 0.7463 0.6925 0.5495 0.6837 0.7400 0.7894 0.1040 0.0715 0.1017 0.0899 0.0103 0.5567 0.4852 0.1321 0.2348 0.3677 0.7455 0.2425 0.9954 0.0809 0.0484 0.3965 0.8905 0.7227 0.7350 0.2060 0.7363 0.0538 0.3321 0.7772 0.6679 0.0616 0.7990 0.1104 0.9706 0.0867 0.5619 0.4417 0.2973 0.9051 0.6035 0.7802 0.7343 0.1175 0.8669 0.7719 0.1842 0.0133 0.0620 0.5338 0.5261 0.3376 0.0513 0.6407 0.0862 0.2057 0.5972 0.8972 0.2982 0.1092 0.7297 0.6079 0.0729 0.3288 0.3664 0.3883 0.2999 0.1967 0.0464 0.8258 0.7073 0.7413 0.0885 0.6538 0.3692 0.5518 0.1341 0.0934 0.5054 0.3381 0.7814 0.1048 0.7984 0.7491 0.6850 0.2290 0.2126 0.3074 0.7614 0.2940 0.2880 0.1279 0.9430 0.5832 0.5979 0.6419 A(:,:,8) = 0.4845 0.1123 0.1098 0.6733 0.0924 0.0986 0.5557 0.9879 0.1544 0.5975 0.1518 0.7844 0.9338 0.4296 0.0078 0.1420 0.1844 0.1704 0.3813 0.3353 0.7819 0.2916 0.1875 0.4517 0.4231 0.1683 0.2120 0.2578 0.1611 0.2992 0.1006 0.6035 0.2662 0.6099 0.6556 0.1962 0.0773 0.3968 0.7581 0.4526 0.2941 0.9644 0.7978 0.0594 0.7229 0.3175 0.9138 0.0740 0.8711 0.4226 0.2374 0.4325 0.4876 0.3158 0.5312 0.3164 0.7067 0.6841 0.3508 0.3596 0.5309 0.6948 0.7690 0.7727 0.1088 0.2176 0.5578 0.4024 0.6855 0.5583 0.0915 0.7581 0.3960 0.6964 0.6318 0.2510 0.3134 0.9828 0.2941 0.7425 0.4053 0.4326 0.2729 0.1253 0.1265 0.8929 0.1662 0.4022 0.5306 0.4243 0.1048 0.6555 0.0372 0.1302 0.1343 0.7032 0.6225 0.6207 0.8324 0.4294 A(:,:,9) = 0.1249 0.7593 0.1636 0.8092 0.0205 0.7519 0.3174 0.6312 0.1841 0.2238 0.0244 0.7406 0.6660 0.7486 0.9237 0.2287 0.8145 0.3551 0.7258 0.3736 0.2902 0.7437 0.8944 0.1202 0.6537 0.0642 0.7891 0.9970 0.3704 0.0875 0.3175 0.1059 0.5166 0.5250 0.9326 0.7673 0.8523 0.2242 0.8416 0.6401 0.6537 0.6816 0.7027 0.3258 0.1635 0.6712 0.5056 0.6525 0.7342 0.1806 0.9569 0.4633 0.1536 0.5464 0.9211 0.7152 0.6357 0.6050 0.5710 0.0451 0.9357 0.2122 0.9535 0.3989 0.7947 0.6421 0.9509 0.3872 0.1769 0.7232 0.4579 0.0985 0.5409 0.4151 0.5774 0.4190 0.4440 0.1422 0.9574 0.3474 0.2405 0.8236 0.6797 0.1807 0.4400 0.3908 0.0600 0.0251 0.2653 0.6606 0.7639 0.1750 0.0366 0.2554 0.2576 0.8161 0.8667 0.4211 0.9246 0.3839 A(:,:,10) = 0.6273 0.2751 0.9891 0.1379 0.9456 0.4116 0.3545 0.7829 0.2243 0.1079 0.0216 0.2486 0.0669 0.2178 0.6766 0.6026 0.9713 0.6938 0.2691 0.1822 0.9106 0.4516 0.9394 0.1821 0.9883 0.7505 0.3464 0.0098 0.6730 0.0991 0.8006 0.2277 0.0182 0.0418 0.7668 0.5835 0.8865 0.8432 0.4775 0.4898 0.7458 0.8044 0.6838 0.1069 0.3367 0.5518 0.4547 0.9223 0.6237 0.1932 0.8131 0.9861 0.7837 0.6164 0.6624 0.5836 0.4134 0.7710 0.2364 0.8959 0.3833 0.0300 0.5341 0.9397 0.2442 0.5118 0.2177 0.0427 0.1771 0.0991 0.6173 0.5357 0.8854 0.3545 0.2955 0.0826 0.1257 0.3782 0.8296 ...
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