Cody

Solution 111969

Submitted on 13 Jul 2012 by Dirk Engel
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')
ans = 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')
ans = 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')
ans = []
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')
ans = 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')
ans(:,:,1) = Columns 1 through 6 0.8529 0.0115 0.3795 0.7805 0.7590 0.4250 0.7713 0.3272 0.1656 0.6712 0.0507 0.7718 0.8292 0.0658 0.4895 0 0.9237 0.3548 0.0877 0.6104 0.6093 0.2504 0.8572 0.1908 0.4288 0.1874 0.0997 0.6875 0.1385 0.5803 0.4443 0.1632 0.4003 0.7043 0.9230 0.9735 0.4840 0.6790 0.9824 0.7349 0.5947 0.1787 0.2118 0.6840 0.8021 0.0177 0.3372 0.4454 0.8015 0.4451 0.9145 0.7088 0.7274 0.8107 0.8593 0.4730 0.8060 0.0828 0.4085 0.6363 Columns 7 through 10 0.9743 0.1561 0.7035 0.8504 0.8907 0.2870 0.1610 0.9015 0.4186 0.2731 0.5964 0.7387 0.6007 0.7816 0.7182 0.3565 0.8163 0.8584 0.8007 0.6628 0.5521 0.8904 0.5010 0.8796 0.1773 0.9748 0.8027 0.7471 0.5543 0.0572 0.7234 0.8568 0.6333 0.0278 0.3907 0.2740 0.9057 0.5771 0.0119 0.0516 ans(:,:,2) = Columns 1 through 6 0.5254 0 0.3973 0.5047 0.5927 0.8256 0.1801 0.4222 0.5959 0.9397 0.0623 0.6902 0.7024 0.9296 0.2860 0.4484 0.8113 0.2756 0.7059 0.0203 0.1868 0.0938 0.8486 0.4620 0.9471 0.1297 0.4834 0.9416 0.9461 0.6786 0.4248 0.4395 0.7433 0.4234 0.4423 0.2494 0.1328 0.4096 0.6953 0.3242 0.9559 0.6207 0.1074 0.2247 0.9441 0.3394 0.8443 0.0388 0.5049 0.3223 0.6253 0.7771 0.8623 0.6135 0.0823 0.8209 0.3339 0.1572 0.7769 0.0213 Columns 7 through 10 0.9915 0.7756 0.6293 0.6681 0.9245 0.7334 0.2023 0.3655 0.4996 0.3198 0.1793 0.3810 0.0424 0.2946 0.3028 0.2318 0.3554 0.1586 0.2840 0.5431 0.3637 0.9904 0.8598 0.5906 0.3267 0.3502 0.4536 0.0946 0.3763 0.0515 0.2887 0.8904 0.2918 0.1567 0.7212 0.6655 0.5200 0.4594 0.6279 0.2910 ans(:,:,3) = Columns 1 through 6 0.0002 0.5012 0.0976 0.5645 0.6582 0.9535 0.5623 0.9112 0.2040 0.7569 0.0734 0.7556 0.4757 0.7425 0.3561 0.2634 0.0390 0.2967 0.8584 0.1235 0.2627 0.5736 0.1746 0.6981 0.0559 0.5706 0.7867 0.5185 0.0411 0 0.9727 0.1093 0.1953 0.7347 0.8222 0.8617 0.9673 0.4373 0.1024 0.1160 0.8639 0.3366 0.6345 0.7306 0.0959 0.7500 0.5855 0.5896 0.9854 0.0368 0.0674 0.7885 0.1058 0.7777 0.2272 0.2650 0.8668 0.5247 0.1343 0.2889 Columns 7 through 10 0.2618 0.9988 0.9818 0.4379 0.9793 0.4268 0.6040 0.2216 0.0258 0.3812 0.0293 0.6339 0.6824 0.2004 0.5617 0.8110 0.5798 0.2102 0.6447 0.8485 0.5865 0.2148 0.1343 0.3811 0.0335 0.0294 0.8324 0.5313 0.7274 0.4524 0.0884 0.4694 0.2647 0.9237 0.4361 0.8463 0.7886 0.2762 0.1286 0.3753 ans(:,:,4) = Columns 1 through 6 0.9968 0.9141 0.1093 0.6994 0.0489 0.5938 0.2517 0.8357 0.9936 0.3644 0.7554 0.1270 0.3152 0.4828 0.8531 0.7866 0.8197 0.7822 0.9334 0.1344 0.5063 0.6724 0.0560 0.8536 0.4061 0.8690 0.2407 0.3214 0.1612 0.1139 0.6442 0.0772 0.7092 0.9719 0.4170 0.6269 0.7220 0.1277 0.0771 0.7878 0.4317 0.3888 0.6264 0.9601 0.1950 0.3426 0.6117 0.7216 0.2090 0.0721 0.9968 0.0040 0.8206 0.3489 0.5867 0.0622 0.0385 0.1984 0.7956 0.6175 Columns 7 through 10 0.7009 0.7543 0.4345 0.7087 0.7825 0.6833 0.7778 0.2931 0.7189 0.3581 0.5877 0.4354 0.9039 0.6917 0.9687 0.6889 0.2763 0.8934 0.7526 0.4839 0.8260 0.4761 0.7919 0.3949 0.5083 0.4139 0.2308 0.6689 0.7997 0.5872 0.3786 0.4647 0.5974 0.6397 0.4500 0.6310 0.5851 0.6163 0.6899 0.9428 ans(:,:,5) = Columns 1 through 6 0.4219 0.9182 0.1043 0.6658 0.1121 0.5376 0.7958 0.1234 0.7580 0.6382 0.3851 0.6972 0.9282 0.1343 0.7495 0.5654 0.3687 0.4149 0.3355 0.5008 0.6121 0.1626 0.5885 0.2618 0.5623 0.7308 0.5199 0.0515 0.4272 0.2798 0.6913 0.4192 0.1723 0.7879 0.6322 0.9835 0.7947 0.9207 0.1266 0.5107 0.5685 0.6371 0.9118 0.8645 0.5891 0.5289 0.8229 0.4148 0.7904 0.5077 0.6758 0.4205 0.1350 0.3572 0.7722 0.7564 0.8652 0.1365 0.9682 0.8769 Columns 7 through 10 0.4188 0.0341 0.5463 0.8328 0.8805 0.3246 0.3106 0.7884 0.7411 0.6614 0.6633 0.9311 0.0453 0.1873 0.0645 0.3035 0.0771 0.2174 0.2572 0.6728 0.1568 0.7740 0.7709 0.9546 0.8183 0.1802 0.9634 0.2550 0.4766 0.4600 0.4473 0.2547 0.4853 0.0097 0.8844 0.2212 0.2476 0.7135 0.9878 0.8893 ans(:,:,6) = Columns 1 through 6 0.6463 0.0398 0.4664 0.3551 0.0329 0.3100 0.9564 0.8722 0.1248 0.9173 0.6036 0.3423 0.3621 0.4212 0.8542 0.1000 0.1868 0.2857 0.0591 0.4125 0.4094 0.1455 0.1701 0.2444 0.9002 0.4058 0.2244 0.4240 0.8179 0.7814 0.8414 0.6931 0.5090 0.3832 0.3721 0.1136 0.2554 0.8536 0.8256 0.3319 0.2470 0.4213 0.8223 0.6516 0.8927 0.9719 0.0284 0.2986 0.2486 0.8139 0.3317 0.3883 0.0832 0.6986 0.2553 0.4299 0.8443 0.0032 0.4122 0.6775 Columns 7 through 10 0.3944 0.5772 0.1224 0.6534 0.8126 0.1326 0.1587 0.3376 0.4117 0.4418 0.3562 0.6756 0.5302 0.9495 0.3793 0.3440 0.4348 0.8424 0.0672 0.8282 0.0069 0.0772 0.1409 0.8605 0.9674 0.8717 0.5385 0.4283 0.4826 0.3510 0.2667 0.2241 0.7276 0.7709 0.4011 0.9778 0.3072 0.2438 0.6712 0.5492 ans(:,:,7) = Columns 1 through 6 0.4952 0.7500 0.6869 0.4541 0.1392 0.2407 0.0281 0.7359 0.4811 0.9555 0.2223 0.7308 0.6903 0.2114 0.1380 0.2829 0.8810 0.0865 0.8649 0.0464 0.6275 0.6770 0.6537 0.8765 0.1342 0.2342 0.8149 0.0475 0.9532 0.2204 0.8364 0.3343 0.6305 0.0207 0.1467 0.4302 0.1068 0.0176 0.4027 0.5493 0.6679 0.9298 0.8851 0.5082 0.9334 0.3060 0.5561 0.8072 0.8386 0.8952 0.1754 0.4258 0.9776 0.2153 0.9327 0.1638 0.0254 0.8102 0.6331 0.6679 Columns 7 through 10 0.8026 0.9178 0.1822 0.4770 0.2678 0.7927 0.4658 0.1571 0.0241 0.8257 0.5491 0.8050 0.1817 0.3067 0.9344 0.8776 0.2996 0.8257 0.8572 0.9972 0.5260 0.7265 0.1648 0.7789 0.3566 0.9277 0.0086 0.2975 0.6366 0.1571 0.0236 0.0512 0.0118 0.7192 0.8685 0.6234 0.7468 0.7389 0.9204 0.5862 ans(:,:,8) = Columns 1 through 6 0.6570 0.3246 0.5636 0.6666 0.8759 0.5522 0.6649 0.4016 0.9183 0.7819 0.9499 0.2966 0.4010 0.4260 0.1416 0.3874 0.2839 0.4223 0.7283 0.7566 0.6718 0.6606 0.2387 0.2055 0.3338 0.4511 0.7495 0.6714 0.7106 0.0872 0.0373 0.8934 0.0738 0.6280 0.2671 0.0455 0.0845 0.7424 0.8101 0.3779 0.1811 0.6971 0.7697 0.1108 0.5550 0.4675 0.3664 0.1689 0.8624 0.9732 0.3942 0.4600 0.4516 0.2798 0.0102 0.4388 0.9758 0.2123 0.6732 0.2720 Columns 7 through 10 0.1151 0.4089 0.9450 0.8918 0.8653 0.1723 0.5922 0.9990 0.1944 0.3439 0.6524 0.9242 0.3920 0.1190 0.4815 0.5305 0.1469 0.0286 0.8310 0.4077 0.4199 0.3714 0.9751 0.0931 0.1880 0.6591 0.9208 0.8745 0.2667 0.6750 0.7611 0.2141 0.9509 0.3657 0.0690 0.5468 0.2045 0.9422 0.3970 0.5012 ans(:,:,9) = Columns 1 through 6 0.1512 0.7006 0.7306 0.7377 0.1210 0.7608 0.6498 0.1195 0.4094 0.7027 0.9940 0.4463 0.9038 0.3395 0.4438 0.2033 0.5391 0.4320 0.6098 0.3890 0.0515 0.1864 0.9727 0.8256 0.2368 0.9783 0.3468 0.8725 0.0807 0.7740 0.0995 0.7529 0.7667 0.8936 0.3287 0.8882 0.1109 0.1278 0.4141 0.3998 0.3263 0.2320 0.0864 0.3617 0.2897 0.4188 0.8863 0.8566 0.6767 0.6379 0.4520 0.9929 0.3804 0.0326 0.5106 0.2342 0.7967 0.3980 0.6507 0.2277 Columns 7 through 10 0.3877 0.8418 0.7570 0.5295 0.3687 0.4131 0.7205 0.8729 0.4775 0.8048 0.3382 0.4255 0.9488 0.8536 0.2695 0.6476 0.3564 0.7696 0.4905 0.5473 0.3713 0.1927 0.4564 0.8274 0.3465 0.2373 0.4438 0.6849 0.4541 0.6438 0.0227 0.4717 0.9948 0.0030 0.3528 0.9256 0.7422 0.6418 0.7658 0.2445 ans(:,:,10) = Columns 1 through 6 0.4232 0.7903 0.4687 0.7453 0.0858 0.7792 0.5927 0.2312 0.5325 0.9426 0.5338 0.2857 0.1550 0.2093 0.8939 0.4056 0.5072 0.4595 0.8236 0.2043 0.4716 0.9764 0.5387 0.5212 0.3123 0.4...
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')
ans = Columns 1 through 10 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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 ans = 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))
ans = 13.3000