Cody

Solution 1591099

Submitted on 24 Jul 2018 by Mohammed Shafiq
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')

A = 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')

A = 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')

A = []

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

A = 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')

A(:,:,1) = 0.8941 0.3685 0.8246 0.8908 0.9135 0.4446 0.6067 0.4058 0.9516 0.7853 0.9667 0.9277 0.6684 0.9849 0.4680 0.5003 0.0735 0.7181 0.0586 0.6373 0.4587 0.7215 0.9870 0 0.1237 0.6640 0.0350 0.4346 0.6239 0.9640 0.0072 0.8973 0.5700 0.1769 0.4254 0.1508 0.7783 0.8105 0.7876 0.6010 0.5319 0.6432 0.1640 0.8770 0.9403 0.2647 0.7010 0.2117 0.7706 0.2805 0.9786 0.4045 0.9055 0.2704 0.8747 0.3732 0.6999 0.3556 0.7451 0.0487 0.8328 0.1658 0.1939 0.5547 0.7368 0.4562 0.9814 0.8428 0.3034 0.6066 0.8710 0.1054 0.3735 0.6649 0.9549 0.4714 0.2079 0.8721 0.4237 0.1863 0.6310 0.6855 0.8511 0.7429 0.6825 0.4819 0.9287 0.8442 0.2013 0.2615 0.3768 0.5436 0.7374 0.4277 0.4613 0.8032 0.5558 0.4115 0.0783 0.1493 A(:,:,2) = 0.2714 0 0.6100 0.8100 0.6122 0.7217 0.4467 0.5884 0.3935 0.8684 0.8100 0.6556 0.6372 0.9415 0.0175 0.0054 0.1543 0.2179 0.6460 0.8827 0.7187 0.1243 0.1771 0.7107 0.0204 0.6228 0.9576 0.7870 0.7337 0.1167 0.6713 0.0923 0.0870 0.4425 0.7746 0.5939 0.9189 0.3996 0.4131 0.8273 0.3211 0.4039 0.2672 0.6396 0.3687 0.1198 0.3340 0.8125 0.1513 0.6716 0.6680 0.3049 0.8170 0.1904 0.7951 0.3520 0.7618 0.5475 0.1929 0.4538 0.8294 0.1404 0.9839 0.8954 0.1508 0.6419 0.6757 0.7564 0.9338 0.3634 0.9642 0.4113 0.6899 0.8963 0.6193 0.5722 0.9554 0.9295 0.9169 0.3629 0.3890 0.2119 0.4533 0.1236 0.2185 0.6541 0.2399 0.9712 0.9755 0.8886 0.9081 0.4922 0.4681 0.6378 0.2715 0.6561 0.0052 0.4488 0.0009 0.6685 A(:,:,3) = 0.9581 0.3964 0.8178 0.2789 0.5196 0.0687 0.1335 0.7796 0.0473 0.0374 0.0510 0.8014 0.1258 0.6349 0.0159 0.2116 0.7439 0.1692 0.9594 0.6164 0.6508 0.5403 0.7808 0.7490 0.3334 0.1178 0.2961 0.2932 0.5240 0.6384 0.3984 0.4088 0.7004 0.7505 0.4321 0.5346 0.7176 0.4719 0.2097 0.7665 0.4245 0.3046 0.0774 0.9100 0.0257 0 0.9871 0.5183 0.3959 0.3924 0.8162 0.2242 0.7308 0.9345 0.4767 0.6689 0.4730 0.6271 0.6707 0.7444 0.9972 0.5211 0.2395 0.3776 0.2134 0.2340 0.9968 0.7030 0.1520 0.5808 0.6695 0.9750 0.6911 0.3577 0.3085 0.6115 0.2374 0.4326 0.6250 0.7291 0.4416 0.0785 0.9490 0.6626 0.4163 0.6903 0.7942 0.3099 0.7086 0.9846 0.6725 0.7285 0.9982 0.7173 0.2883 0.1560 0.6565 0.3579 0.8760 0.3843 A(:,:,4) = 0.3828 0.1118 0.8708 0.1662 0.7474 0.8965 0.2154 0.2301 0.1648 0.3901 0.8126 0.2066 0.1464 0.7958 0.1704 0.0676 0.5281 0.8789 0.4623 0.1380 0.1464 0.3832 0.4789 0.0159 0.5460 0.7735 0.7186 0.3294 0.7660 0.6569 0.7426 0.2571 0.3794 0.6884 0.2368 0.1536 0.9832 0.3412 0.7263 0.7587 0.6898 0.2301 0.8249 0.4978 0.2634 0.8957 0.9972 0.3870 0.0369 0.8461 0.5204 0.4000 0.8640 0.3516 0.0731 0.9058 0.0788 0.8748 0.2076 0.4624 0.2475 0.6354 0.9222 0.3442 0.1574 0.7269 0.7459 0.9839 0.2353 0.8861 0.0404 0.9795 0.8589 0.1291 0.2974 0.6424 0.6984 0.7645 0.6550 0.5558 0.5938 0.4329 0.6539 0.3489 0.2611 0.2792 0.3557 0.0953 0.0503 0.8997 0.7132 0.8782 0.4695 0.7643 0.5772 0.6362 0.4797 0.6951 0.9233 0.3901 A(:,:,5) = 0.6071 0.0740 0.0079 0.0116 0.6651 0.8278 0.8993 0.8195 0.6179 0.7265 0.4432 0.7620 0.9263 0.8840 0.0191 0.0638 0.9713 0.8266 0.7261 0.4072 0.3369 0.6568 0.4312 0.2643 0.3266 0.3176 0.7134 0.9536 0.5682 0.3530 0.6299 0.2745 0.6510 0.7705 0.8999 0.7683 0.9949 0.7280 0.0429 0.7201 0.1232 0.7348 0.6297 0.7577 0.2698 0.9377 0.2070 0.1738 0.6416 0.6973 0.0919 0.7129 0.7759 0.2380 0.7586 0.0567 0.4923 0.6737 0.5045 0.2687 0.8491 0.6636 0.5926 0.0668 0.9433 0.0523 0.6186 0.8275 0.4869 0.4417 0.1814 0.1719 0.6255 0.2454 0.4400 0.8195 0.7628 0.1720 0.3440 0.3125 0.0664 0.1157 0.0199 0.4960 0.9680 0.7718 0.3463 0.1404 0.1941 0.7921 0.3737 0.9700 0.5495 0.7067 0.5125 0.4338 0.1693 0.4588 0.0393 0.3296 A(:,:,6) = 0.4406 0.2857 0.4466 0.8339 0.1069 0.4586 0.7976 0.2822 0.5722 0.9408 0.3187 0.6061 0.4916 0.1460 0.9597 0.8971 0.7955 0.5697 0.6384 0.1638 0.7839 0.5495 0.0057 0.5605 0.7390 0.4410 0.8793 0.4713 0.3910 0.3262 0.0692 0.0313 0.0539 0.5017 0.1288 0.5129 0.6586 0.5599 0.8510 0.8148 0.4709 0.7017 0.8304 0.4081 0.4249 0.8690 0.1197 0.0457 0.1424 0.9469 0.1281 0.2940 0.0502 0.4452 0.6191 0.7787 0.6956 0.0463 0.5966 0.1508 0.4321 0.8039 0.0515 0.5457 0.5748 0.1708 0.3508 0.2582 0.2999 0.0305 0.5262 0.9819 0.6016 0.6806 0.2346 0.6043 0.3949 0.3600 0.5745 0.2611 0.8277 0.6382 0.9038 0.5520 0.1437 0.5208 0.4257 0.0654 0.9289 0.4869 0.5926 0.0473 0.4299 0.4150 0.0200 0.9293 0.3168 0.5786 0.7537 0.0904 A(:,:,7) = 0.8424 0.8714 0.6464 0.6552 0.9454 0.8184 0.9905 0.9677 0.7238 0.4293 0.3551 0.1000 0.4665 0.0817 0.3940 0.9845 0.8938 0.2071 0.2229 0.1797 0.4340 0.6965 0.2719 0.0220 0.9645 0.2817 0.8508 0.5266 0.8398 0.9124 0.9334 0.4967 0.0115 0.4554 0.8713 0.8425 0.2590 0.5625 0.7340 0.7222 0.0034 0.6094 0.8859 0.5090 0.6352 0.3742 0.8192 0.7821 0.0971 0.2991 0.0093 0.9677 0.9876 0.4985 0.0866 0.5379 0.5010 0.3386 0.9648 0.5454 0.2729 0.3214 0.5989 0.0365 0.4275 0.6921 0.3668 0.5045 0.3236 0.2682 0.3637 0.9537 0.8112 0.8916 0.4156 0.1969 0.5420 0.3429 0.3911 0.0921 0.9789 0.2653 0.3830 0.5774 0.1034 0.2362 0.9800 0.4752 0.5647 0.7723 0.0153 0.2679 0.1405 0.7058 0.3613 0.8022 0.7479 0.0140 0.8274 0.1813 A(:,:,8) = 0.7741 0.1308 0.8969 0.2105 0.0497 0.4334 0.4713 0.0765 0.8182 0.4637 0.6741 0.2790 0.9975 0.8805 0.0649 0.4998 0.8706 0.4096 0.1730 0.0080 0.7128 0.6874 0.2069 0.2792 0.3936 0.8097 0.7544 0.2672 0.6480 0.9982 0.3326 0.7727 0.1613 0.3636 0.9609 0.3264 0.8506 0.8083 0.7214 0.0869 0.1269 0.5219 0.8760 0.3475 0.0087 0.5696 0.7062 0.6507 0.6813 0.3818 0.0659 0.7279 0.7982 0.0220 0.3751 0.0356 0.1051 0.2091 0.4563 0.5680 0.2094 0.5559 0.3322 0.3650 0.2376 0.0980 0.2588 0.1529 0.6107 0.0464 0.6904 0.3351 0.7475 0.2585 0.5616 0.9421 0.8970 0.8730 0.9075 0.9504 0.0793 0.9820 0.8229 0.2119 0.8874 0.4793 0.5730 0.8912 0.1208 0.2059 0.9637 0.8749 0.6608 0.6316 0.8322 0.3601 0.3435 0.0009 0.6515 0.8091 A(:,:,9) = 0.8367 0.9973 0.7482 0.6391 0.3564 0.2189 0.3047 0.8473 0.9843 0.6716 0.0009 0.2890 0.1782 0.4386 0.9013 0.0254 0.9341 0.1334 0.3350 0.2892 0.9555 0.0225 0.3351 0.4706 0.3562 0.0766 0.0902 0.8509 0.1706 0.1047 0.8420 0.8163 0.5935 0.0618 0.1669 0.3034 0.7401 0.6294 0.6399 0.1719 0.0366 0.1786 0.9666 0.3789 0.1573 0.0182 0.6748 0.0390 0.9831 0.9394 0.2905 0.7331 0.7993 0.1679 0.3061 0.5484 0.3946 0.2465 0.7381 0.1176 0.2902 0.4677 0.5648 0.2128 0.4071 0.7187 0.4497 0.9696 0.9544 0.2873 0.2800 0.7909 0.6657 0.4005 0.2797 0.6925 0.1915 0.1779 0.0524 0.9103 0.6455 0.4766 0.4114 0.4766 0.1967 0.1594 0.4336 0.0501 0.0059 0.1947 0.8583 0.8355 0.1569 0.1136 0.2908 0.6369 0.1148 0.5199 0.2997 0.7045 A(:,:,10) = 0.4303 0.2665 0.7954 0.5345 0.3214 0.6274 0.2504 0.8354 0.1454 0.2496 0.7517 0.6264 0.6132 0.3896 0.2096 0.3802 0.9969 0.8978 0.3688 0.4424 0.5889 0.0467 0.4181 0.3729 0.4235 0.4299 0.0156 0.4415 0.8344 0.2125 0.0744 0.2427 0.7021 0.3994 0.3967 0.1066 0.0249 0.1099 0.9897 0.8039 0.9143 0.1663 0.4017 0.6020 0.7533 0.4030 0.8540 0.5427 0.0148 0.2158 0.0311 0.6661 0.4474 0.6135 0.8655 0.7697 0.4762 0.7536 0.5959 0.8313 0.6968 0.2910 0.8564 0.1076 0.4500 0.4563 0.5697 0.9205 0.1658 0.7290 0.7856 0.5389 0.7853 0.2527 0.6804 0.8978 ...

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

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

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 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
A= 13.3; B = A; assert(isequal(your_fcn_name(A),B))

A = 13.3000