Cody

Solution 1403642

Submitted on 3 Jan 2018 by Raymundo Carranza
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
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')

B = 15 0 3

2   Pass
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')

B = 0

3   Pass
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')

B = []

4   Pass
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')

B = 0 0 0 0 0 8 0 25 2

5   Pass
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')

B(:,:,1) = 0.9682 0.5280 0.4066 0.5388 0.6466 0.3387 0.1618 0.4058 0.5216 0.8521 0.5328 0.2838 0.8126 0.7475 0.1215 0.5782 0.0178 0.5041 0.6319 0.8054 0.6045 0.6361 0.6110 0 0.6621 0.6663 0.5120 0.9737 0.7676 0.8511 0.4062 0.9272 0.9926 0.6890 0.3962 0.6179 0.6828 0.5390 0.5227 0.2267 0.9153 0.5663 0.0035 0.4139 0.1774 0.1603 0.3333 0.3933 0.9087 0.2532 0.9493 0.7294 0.0024 0.8834 0.6887 0.6139 0.4305 0.9159 0.3261 0.9015 0.4433 0.8558 0.6210 0.6957 0.8317 0.3814 0.3348 0.6549 0.3601 0.1223 0.2217 0.1866 0.2708 0.8331 0.5601 0.4686 0.3091 0.0855 0.3788 0.9543 0.9586 0.2829 0.6310 0.3710 0.9781 0.3596 0.2802 0.1602 0.7548 0.3351 0.1384 0.4757 0.3395 0.3826 0.0939 0.5775 0.2318 0.7614 0.6185 0.8822 B(:,:,2) = 0.4771 0 0.7750 0.2827 0.3715 0.0409 0.3001 0.1713 0.8855 0.7645 0.5916 0.7930 0.4062 0.9153 0.7829 0.2094 0.8315 0.5995 0.1223 0.7791 0.0186 0.8172 0.9905 0.1009 0.0781 0.3012 0.3485 0.0289 0.1409 0.5052 0.3174 0.3621 0.9278 0.1075 0.9961 0.4371 0.5473 0.1207 0.3687 0.5629 0.1038 0.1772 0.9837 0.8392 0.8382 0.8076 0.7587 0.3302 0.8345 0.2277 0.5834 0.2680 0.4413 0.0868 0.5000 0.6555 0.1372 0.7563 0.2264 0.9151 0.0631 0.7457 0.4576 0.3316 0.7353 0.0548 0.2377 0.4210 0.1519 0.2659 0.3173 0.9055 0.7486 0.7710 0.1069 0.7732 0.2983 0.9774 0.1513 0.7239 0.5869 0.2115 0.1866 0.8632 0.0999 0.6964 0.4488 0.7312 0.0923 0.4834 0.7883 0.9753 0.8214 0.8170 0.6407 0.2796 0.1393 0.0566 0.1495 0.6576 B(:,:,3) = 0.3135 0.4741 0.5373 0.7228 0.1299 0.9811 0.9759 0.7251 0.4287 0.2443 0.8021 0.3892 0.7421 0.6969 0.8211 0.6996 0.6264 0.3387 0.1182 0.5816 0.7529 0.0955 0.3860 0.1607 0.3081 0.1175 0.0312 0.5636 0.8748 0.7003 0.4396 0.7285 0.9542 0.2994 0.4533 0.7526 0.6991 0.8549 0.4272 0.9490 0.1561 0.2772 0.2325 0.7003 0.1000 0 0.6188 0.4783 0.2382 0.8545 0.8943 0.2920 0.3477 0.9908 0.2889 0.9821 0.3795 0.5643 0.6088 0.2245 0.1473 0.0383 0.1029 0.0956 0.2174 0.1904 0.2057 0.5641 0.3842 0.5178 0.2983 0.7327 0.5495 0.6936 0.1229 0.0565 0.2781 0.4938 0.2591 0.5572 0.4869 0.0858 0.2546 0.2000 0.8428 0.7057 0.3998 0.2161 0.2229 0.6195 0.2571 0.2096 0.1504 0.4876 0.2574 0.3120 0.4537 0.2669 0.0169 0.6956 B(:,:,4) = 0.4565 0.2005 0.9601 0.1315 0.8145 0.7985 0.0484 0.3647 0.2059 0.2782 0.9316 0.8179 0.6215 0.5490 0.9702 0.3743 0.1841 0.6829 0.0708 0.2432 0.3239 0.1843 0.2202 0.7823 0.8403 0.2896 0.3184 0.3823 0.5804 0.3258 0.7747 0.5851 0.5956 0.0577 0.9715 0.1989 0.5192 0.6162 0.2604 0.6912 0.0212 0.9594 0.4367 0.6501 0.4450 0.5228 0.7941 0.4759 0.0448 0.4459 0.1866 0.5595 0.8296 0.3053 0.9011 0.2209 0.6524 0.7269 0.9989 0.8355 0.6094 0.7031 0.2113 0.1761 0.1023 0.2652 0.0773 0.5727 0.5596 0.1739 0.1954 0.3171 0.6015 0.2199 0.7382 0.1630 0.6892 0.4705 0.5290 0.0321 0.3240 0.1384 0.4611 0.4826 0.9746 0.6441 0.0838 0.1432 0.9018 0.6256 0.1761 0.4199 0.5021 0.3064 0.4465 0.2000 0.2689 0.8858 0.0305 0.2228 B(:,:,5) = 0.9487 0.6583 0.9326 0.9467 0.3385 0.7966 0.1920 0.5124 0.9846 0.4781 0.8653 0.0589 0.1710 0.0931 0.1872 0.1855 0.2735 0.0133 0.8449 0.5171 0.1682 0.9664 0.0758 0.5616 0.2607 0.2148 0.6023 0.0078 0.3561 0.7512 0.5279 0.9205 0.3896 0.8221 0.2900 0.4409 0.2757 0.8992 0.7878 0.2924 0.3216 0.6802 0.8886 0.1661 0.8665 0.8109 0.2581 0.7743 0.5501 0.8423 0.3301 0.0078 0.2311 0.3888 0.4160 0.2654 0.4390 0.3776 0.1549 0.5153 0.0543 0.5018 0.3056 0.2451 0.5357 0.5795 0.4578 0.5499 0.9798 0.6359 0.0314 0.6695 0.7707 0.4139 0.5162 0.3774 0.2036 0.1782 0.0295 0.0334 0.2889 0.3797 0.8381 0.9434 0.9870 0.9761 0.3576 0.8549 0.6888 0.3042 0.5054 0.5547 0.3995 0.1788 0.4865 0.0429 0.3266 0.2489 0.2163 0.1866 B(:,:,6) = 0.1395 0.1124 0.2541 0.0889 0.2008 0.5571 0.8228 0.3121 0.1058 0.4395 0.6937 0.4812 0.9592 0.6077 0.3607 0.0349 0.4100 0.6909 0.5567 0.9439 0.9464 0.8616 0.5083 0.5830 0.3299 0.1936 0.6397 0.6792 0.0755 0.9565 0.6911 0.2237 0.7428 0.5041 0.4659 0.1605 0.1494 0.8369 0.8309 0.5609 0.8273 0.7255 0.3718 0.3711 0.5542 0.5348 0.0379 0.4314 0.8483 0.9072 0.3069 0.1014 0.8464 0.4258 0.0434 0.6798 0.4652 0.6403 0.2037 0.2852 0.4744 0.4827 0.6557 0.5493 0.1224 0.1662 0.6163 0.2079 0.9012 0.9021 0.5008 0.9166 0.3239 0.4786 0.0187 0.4880 0.4586 0.0604 0.1003 0.4920 0.0025 0.4963 0.3702 0.7882 0.9111 0.0131 0.2286 0.9664 0.5138 0.4424 0.4973 0.3918 0.6443 0.4141 0.3050 0.8297 0.9336 0.2439 0.1495 0.0213 B(:,:,7) = 0.2053 0.5228 0.0554 0.2616 0.9459 0.5987 0.6265 0.8550 0.0262 0.0132 0.9322 0.2811 0.6326 0.2376 0.0948 0.2461 0.5638 0.7689 0.5915 0.2151 0.8051 0.6034 0.7056 0.8124 0.6462 0.8454 0.7537 0.7848 0.4107 0.9258 0.3733 0.3979 0.8705 0.6055 0.5792 0.3573 0.3876 0.6497 0.3850 0.5341 0.6490 0.9073 0.7779 0.7307 0.1253 0.3305 0.7288 0.8588 0.1656 0.7575 0.0608 0.2871 0.9034 0.4143 0.3753 0.0186 0.7031 0.4473 0.2142 0.7967 0.4892 0.3977 0.4524 0.4782 0.1744 0.5003 0.6165 0.1866 0.8349 0.4012 0.4971 0.3550 0.3468 0.6808 0.0184 0.7382 0.8413 0.3694 0.8230 0.3237 0.4041 0.4326 0.7837 0.4662 0.2166 0.0444 0.7329 0.2697 0.6236 0.3552 0.3961 0.7399 0.1356 0.4769 0.5536 0.7871 0.8079 0.5966 0.0460 0.2071 B(:,:,8) = 0.7887 0.4779 0.5809 0.7406 0.6604 0.5951 0.6485 0.5793 0.5231 0.2674 0.2730 0.0375 0.7174 0.8194 0.8129 0.1954 0.0497 0.5146 0.5162 0.3713 0.5375 0.6611 0.0076 0.6944 0.5858 0.4412 0.1557 0.5569 0.7398 0.5571 0.3895 0.1660 0.8619 0.9479 0.9993 0.2233 0.3061 0.9209 0.4117 0.1388 0.5679 0.5570 0.9043 0.5771 0.8375 0.2359 0.2177 0.9436 0.3552 0.0645 0.7637 0.2177 0.6997 0.2110 0.0821 0.6396 0.0233 0.2017 0.6612 0.9860 0.3132 0.5584 0.4122 0.9843 0.3978 0.7547 0.7126 0.1231 0.4581 0.3947 0.8186 0.8418 0.4083 0.8322 0.1492 0.7726 0.4168 0.1554 0.7390 0.9781 0.5082 0.8308 0.5175 0.1434 0.6521 0.9368 0.0638 0.3951 0.0997 0.1133 0.8979 0.4970 0.5202 0.6903 0.2690 0.5032 0.3170 0.4028 0.8393 0.5214 B(:,:,9) = 0.3102 0.5202 0.4687 0.2298 0.3351 0.7159 0.4479 0.3496 0.0545 0.4997 0.6826 0.7400 0.2257 0.4002 0.4156 0.9478 0.0481 0.7723 0.7588 0.6332 0.5733 0.9579 0.1099 0.8077 0.2089 0.9269 0.0783 0.2588 0.0515 0.9960 0.5394 0.1943 0.5196 0.2694 0.6157 0.8552 0.5498 0.6540 0.9803 0.3643 0.3303 0.4088 0.3394 0.0802 0.6345 0.0444 0.1253 0.3166 0.3979 0.1608 0.0732 0.7658 0.0152 0.5652 0.4732 0.2359 0.7247 0.3502 0.5453 0.8519 0.8819 0.4872 0.7859 0.4880 0.1864 0.5400 0.5425 0.9822 0.5706 0.9986 0.0830 0.1710 0.5458 0.3664 0.4437 0.1175 0.6323 0.3223 0.8574 0.0902 0.1211 0.8654 0.3194 0.6823 0.4307 0.4361 0.0483 0.0480 0.6780 0.3344 0.1049 0.9367 0.6651 0.0337 0.3967 0.0384 0.0131 0.3961 0.0748 0.0533 B(:,:,10) = 0.7250 0.2416 0.3838 0.7637 0.3608 0.5466 0.7198 0.5544 0.8533 0.1468 0.4317 0.1261 0.9576 0.0234 0.6415 0.4344 0.9498 0.0209 0.9340 0.7590 0.7077 0.7852 0.0852 0.7194 0.7378 0.6468 0.5910 0.3052 0.7328 0.2669 0.9236 0.8150 0.3355 0.9575 0.1503 0.9434 0.3839 0.4068 0.6307 0.2554 0.4754 0.4377 0.3268 0.4324 0.0887 0.6399 0.1340 0.9229 0.3467 0.6794 0.3611 0.1939 0.3698 0.4193 0.4986 0.2241 0.9172 0.0690 0.0152 0.3060 0.4927 0.5590 0.7599 0.8992 0.7913 0.1079 0.3209 0.9665 0.6329 0.5876 0.8641 0.6125 0.3483 0.5432 0.2978 0.1648 ...

6   Pass
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')

B = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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

7   Pass
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 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

8   Pass
A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

B = 13.3000