Cody

Solution 2052272

Submitted on 9 Dec 2019 by Petr Stieber
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.4987 0.1265 0.7848 0.3635 0.7204 0.1558 0.5371 0.8769 0.7736 0.5091 0.7458 0.2165 0.9294 0.0670 0.2589 0.4650 0.6030 0.8973 0.1690 0.2566 0.3965 0.3639 0.9499 0 0.4663 0.7345 0.4343 0.3113 0.9996 0.9972 0.4525 0.2510 0.8589 0.3693 0.2187 0.9430 0.1347 0.7427 0.8309 0.7037 0.6818 0.5534 0.2278 0.4896 0.0990 0.7894 0.9201 0.3344 0.8042 0.9468 0.3192 0.8670 0.1473 0.0928 0.2833 0.7458 0.8522 0.8626 0.9986 0.3920 0.5852 0.8944 0.1948 0.0848 0.8595 0.4138 0.2832 0.4541 0.0741 0.5826 0.4433 0.3470 0.1056 0.3596 0.6498 0.8141 0.0917 0.4778 0.6989 0.4936 0.9721 0.4352 0.1738 0.3085 0.0630 0.9723 0.6380 0.3343 0.1210 0.5872 0.1904 0.9158 0.3004 0.1086 0.0909 0.0702 0.9475 0.4457 0.7074 0.3809 B(:,:,2) = 0.3006 0 0.9517 0.5192 0.1982 0.3022 0.0108 0.8902 0.1760 0.9800 0.8955 0.9644 0.2135 0.2428 0.1865 0.5860 0.1137 0.0519 0.0356 0.0667 0.1699 0.9016 0.0830 0.4198 0.1407 0.5507 0.4318 0.3631 0.5404 0.5447 0.4205 0.9708 0.1111 0.8355 0.3102 0.8691 0.4599 0.4105 0.0983 0.4959 0.7350 0.5797 0.1429 0.6655 0.6735 0.2120 0.9968 0.1155 0.2270 0.7928 0.3255 0.9021 0.2144 0.5756 0.6438 0.8576 0.6679 0.8070 0.6455 0.6022 0.5664 0.9145 0.8298 0.7873 0.2879 0.7028 0.8536 0.8801 0.9945 0.3740 0.5906 0.9889 0.4053 0.3806 0.4352 0.5332 0.2825 0.5367 0.2119 0.8108 0.0691 0.0463 0.0354 0.4476 0.6678 0.2667 0.1795 0.0399 0.7524 0.4607 0.7485 0.5314 0.6780 0.8612 0.7199 0.5198 0.8601 0.2403 0.8124 0.9846 B(:,:,3) = 0.0209 0.3964 0.3244 0.7327 0.0644 0.5198 0.5496 0.1646 0.5528 0.7463 0.4198 0.1748 0.7056 0.3370 0.4956 0.7813 0.6572 0.9064 0.3619 0.5844 0.2234 0.2932 0.2469 0.3995 0.6648 0.6526 0.4711 0.5646 0.8552 0.0924 0.9091 0.1476 0.4325 0.3837 0.9601 0.8869 0.0417 0.4042 0.2513 0.9738 0.1172 0.9858 0.2373 0.1814 0.6318 0 0.4966 0.9209 0.5527 0.6400 0.9991 0.0319 0.4861 0.9807 0.9638 0.9961 0.7281 0.4774 0.2803 0.0177 0.9813 0.2488 0.7176 0.8942 0.6295 0.3861 0.1849 0.6658 0.8411 0.4897 0.1408 0.9788 0.8661 0.9750 0.1996 0.0449 0.2191 0.3825 0.4208 0.8522 0.4401 0.5514 0.5224 0.4014 0.8095 0.7543 0.1657 0.3742 0.3958 0.3945 0.5365 0.0127 0.6949 0.8645 0.0767 0.1976 0.9696 0.9880 0.2355 0.3475 B(:,:,4) = 0.4239 0.2122 0.1396 0.3956 0.2139 0.3729 0.6082 0.4458 0.3927 0.4706 0.1118 0.1017 0.1947 0.9466 0.2251 0.8516 0.6275 0.8527 0.2835 0.0705 0.4864 0.9048 0.1911 0.9586 0.1492 0.8687 0.1592 0.8146 0.3533 0.1425 0.7359 0.4008 0.3833 0.4061 0.1346 0.2659 0.4224 0.9738 0.0868 0.0481 0.8288 0.9732 0.9203 0.8591 0.1864 0.4720 0.3606 0.4500 0.1160 0.5757 0.6562 0.8324 0.7684 0.5239 0.6514 0.3673 0.9058 0.6742 0.9972 0.7148 0.2903 0.9320 0.3908 0.2917 0.2834 0.0170 0.0153 0.4306 0.4866 0.8120 0.8635 0.4267 0.5698 0.1199 0.6881 0.1716 0.0018 0.1225 0.6811 0.3223 0.4127 0.0880 0.8582 0.9645 0.0045 0.4700 0.0257 0.4671 0.1740 0.1162 0.7395 0.4816 0.7866 0.9302 0.0217 0.4267 0.1001 0.7295 0.6023 0.9748 B(:,:,5) = 0.7173 0.4478 0.1339 0.9172 0.5854 0.7902 0.6215 0.5068 0.6856 0.6063 0.2976 0.4626 0.4724 0.1725 0.8817 0.0317 0.7261 0.4371 0.1365 0.4531 0.8747 0.3506 0.1624 0.9709 0.8195 0.6887 0.0466 0.4736 0.5332 0.7264 0.3333 0.0926 0.7689 0.3942 0.5963 0.9483 0.6793 0.7674 0.1177 0.8237 0.8754 0.0774 0.2169 0.4743 0.2469 0.7079 0.9066 0.8052 0.2128 0.6962 0.8838 0.3225 0.3897 0.4785 0.6191 0.9853 0.2223 0.3185 0.1468 0.9452 0.9245 0.2783 0.7596 0.2763 0.1266 0.5661 0.6244 0.1178 0.2047 0.3070 0.9684 0.7768 0.2132 0.7690 0.2997 0.4188 0.5950 0.8924 0.3753 0.8827 0.5982 0.2212 0.4982 0.1958 0.0734 0.7955 0.4823 0.6379 0.0980 0.3845 0.8373 0.2469 0.8267 0.8477 0.4756 0.5901 0.0163 0.0671 0.9783 0.9815 B(:,:,6) = 0.1137 0.6594 0.6134 0.7025 0.1194 0.3549 0.6642 0.9982 0.2826 0.8424 0.6833 0.2987 0.9666 0.1453 0.5265 0.1546 0.0164 0.8006 0.7822 0.8805 0.1638 0.7762 0.5412 0.7340 0.7979 0.9832 0.2864 0.1347 0.9218 0.1949 0.8531 0.0136 0.1289 0.2712 0.4930 0.3125 0.8728 0.9028 0.9576 0.7857 0.3336 0.6664 0.1279 0.4189 0.4642 0.3607 0.1932 0.1306 0.1937 0.9457 0.2013 0.4864 0.6215 0.6217 0.9662 0.9533 0.7375 0.4205 0.5334 0.2566 0.3109 0.9952 0.3688 0.3887 0.7037 0.0905 0.7409 0.7392 0.0951 0.3535 0.0632 0.4418 0.4748 0.8552 0.7789 0.1346 0.3111 0.0177 0.6667 0.5176 0.2956 0.3648 0.3197 0.0100 0.7057 0.2393 0.6717 0.5580 0.3155 0.4722 0.7023 0.2668 0.6332 0.5027 0.9959 0.8385 0.2033 0.6045 0.6311 0.9747 B(:,:,7) = 0.9841 0.4078 0.1598 0.4902 0.6263 0.8821 0.9247 0.2007 0.3887 0.5027 0.7920 0.0381 0.6710 0.7919 0.5888 0.9846 0.2862 0.9086 0.3835 0.6366 0.5932 0.9070 0.0949 0.9937 0.3670 0.4120 0.4111 0.3308 0.4847 0.4136 0.5328 0.3459 0.4743 0.2072 0.5726 0.6487 0.0846 0.3692 0.1451 0.0760 0.9928 0.9851 0.6676 0.1913 0.3269 0.2409 0.0052 0.0042 0.0143 0.6681 0.5775 0.0854 0.6801 0.7278 0.1984 0.6738 0.2802 0.1779 0.6230 0.6255 0.2265 0.8293 0.5370 0.5325 0.7893 0.2299 0.1531 0.8259 0.9062 0.2253 0.5767 0.3430 0.1527 0.0565 0.8842 0.4502 0.3246 0.1144 0.4347 0.1007 0.1110 0.2197 0.1021 0.5390 0.0043 0.4357 0.3674 0.6646 0.7926 0.8570 0.8929 0.1632 0.9570 0.9535 0.1253 0.4098 0.3922 0.3120 0.9280 0.2532 B(:,:,8) = 0.0167 0.0905 0.2306 0.3392 0.5300 0.7259 0.7086 0.3664 0.9382 0.8907 0.3586 0.0135 0.7808 0.8548 0.6113 0.7069 0.9722 0.8941 0.3752 0.5831 0.8890 0.7207 0.9484 0.0174 0.5847 0.0447 0.3530 0.0308 0.6881 0.5210 0.9352 0.3672 0.6586 0.6046 0.3999 0.9573 0.1311 0.0850 0.7169 0.1567 0.0660 0.0318 0.6028 0.4302 0.7903 0.1841 0.6393 0.3528 0.4147 0.2419 0.2326 0.4197 0.6310 0.3854 0.2278 0.2903 0.0045 0.7734 0.5064 0.7211 0.5384 0.6937 0.0684 0.3746 0.5379 0.0607 0.9421 0.9188 0.8861 0.0533 0.4733 0.4492 0.3259 0.1483 0.2952 0.1359 0.6813 0.2040 0.2676 0.8645 0.2808 0.4415 0.3152 0.8998 0.0952 0.6929 0.4367 0.5077 0.0069 0.7583 0.0579 0.5051 0.2044 0.7107 0.4781 0.2818 0.8590 0.4967 0.9761 0.2018 B(:,:,9) = 0.9356 0.7423 0.7704 0.5259 0.5166 0.9604 0.7858 0.1500 0.2917 0.3940 0.4796 0.2763 0.6960 0.8360 0.0972 0.3323 0.6494 0.0448 0.7852 0.9365 0.1426 0.8508 0.6828 0.2213 0.3431 0.7601 0.7995 0.6251 0.9820 0.7063 0.0737 0.7092 0.1911 0.4236 0.1876 0.7528 0.8412 0.2007 0.2725 0.2999 0.1446 0.7903 0.8879 0.0664 0.2932 0.3660 0.0233 0.6842 0.2990 0.9906 0.4059 0.8738 0.3776 0.9830 0.2237 0.0512 0.9260 0.9838 0.0458 0.1729 0.9783 0.1428 0.9001 0.7342 0.8332 0.7707 0.6057 0.7134 0.3973 0.2508 0.2950 0.4916 0.3475 0.6314 0.7875 0.6682 0.5710 0.4113 0.8764 0.2621 0.1066 0.8156 0.2015 0.8109 0.0569 0.6130 0.1156 0.2837 0.0670 0.5253 0.9407 0.0670 0.1591 0.9037 0.9946 0.5374 0.1917 0.6667 0.8335 0.0208 B(:,:,10) = 0.9793 0.7548 0.5663 0.1851 0.7523 0.1358 0.3280 0.3635 0.7406 0.7193 0.2153 0.3712 0.6426 0.4181 0.5087 0.3760 0.6743 0.2788 0.7237 0.5418 0.8771 0.2999 0.5054 0.4120 0.9436 0.2337 0.8890 0.8018 0.6996 0.3327 0.0265 0.8120 0.5777 0.3467 0.0699 0.9751 0.4349 0.8322 0.6497 0.3335 0.1145 0.2867 0.2359 0.8029 0.1382 0.7929 0.4188 0.8510 0.0592 0.1932 0.5598 0.9666 0.7794 0.8163 0.6008 0.5211 0.5845 0.3840 0.6480 0.6081 0.7908 0.5323 0.1950 0.2143 0.4952 0.6048 0.8276 0.0877 0.2308 0.3661 0.7314 0.1742 0.7927 0.3033 0.0925 0.0115 ...

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

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