Cody

Solution 110459

Submitted on 11 Jul 2012 by Khaled Hamed
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.2052 0.5480 0.7424 0.5970 0.8270 0.3747 0.4391 0.5669 0.9374 0.4306 0.3081 0.4369 0.0273 0.6804 0.5134 0 0.4024 0.3043 0.8762 0.3714 0.2409 0.2612 0.8842 0.2909 0.6101 0.0782 0.2600 0.0948 0.7006 0.2425 0.2036 0.4564 0.7590 0.4510 0.2419 0.9367 0.5199 0.0478 0.9933 0.6401 0.7598 0.8602 0.0538 0.7383 0.3567 0.1320 0.2909 0.3972 0.8622 0.0380 0.7529 0.4528 0.2774 0.4794 0.4429 0.9542 0.1100 0.6522 0.0061 0.5650 Columns 7 through 10 0.4896 0.9522 0.7538 0.7290 0.2698 0.5433 0.1319 0.2026 0.9897 0.2514 0.3559 0.2163 0.1837 0.5786 0.3959 0.9763 0.8617 0.9155 0.8855 0.5932 0.0326 0.8956 0.0212 0.3044 0.3320 0.4825 0.8441 0.9677 0.7487 0.4427 0.2881 0.8960 0.6444 0.3118 0.2503 0.1900 0.1692 0.0553 0.4884 0.0018 ans(:,:,2) = Columns 1 through 6 0.7118 0 0.3511 0.1868 0.1739 0.0060 0.8677 0.1133 0.0543 0.2472 0.6256 0.8019 0.1183 0.3546 0.7087 0.0542 0.5751 0.4974 0.0390 0.2419 0.9929 0.6090 0.7510 0.5378 0.5982 0.5603 0.1625 0.7772 0.1535 0.8709 0.6043 0.6127 0.1136 0.5111 0.3568 0.7228 0.5164 0.3008 0.9129 0.0278 0.1440 0.6681 0.0075 0.7981 0.4817 0.9904 0.8506 0.1788 0.6889 0.7956 0.8518 0.5009 0.3379 0.5505 0.9460 0.7811 0.8099 0.3320 0.2752 0.9599 Columns 7 through 10 0.5960 0.2490 0.9469 0.2072 0.8086 0.3864 0.5101 0.3234 0.9845 0.4314 0.7919 0.1109 0.8859 0.8309 0.4522 0.3752 0.2138 0.8246 0.8492 0.3299 0.0346 0.4530 0.3904 0.3421 0.4511 0.3806 0.7384 0.8171 0.0138 0.9259 0.9764 0.5317 0.4737 0.7408 0.5233 0.5211 0.9512 0.7376 0.4299 0.7743 ans(:,:,3) = Columns 1 through 6 0.1203 0.2983 0.5067 0.7750 0.2864 0.5209 0.6255 0.4965 0.3813 0.1653 0.6871 0.2191 0.3466 0.8899 0.0649 0.9122 0.1411 0.8424 0.3346 0.5014 0.3586 0.3192 0.5121 0.6629 0.5746 0.2770 0.2343 0.3298 0.7213 0 0.8639 0.5340 0.2035 0.2042 0.9288 0.7939 0.1986 0.5742 0.8138 0.7672 0.7321 0.4691 0.6725 0.4128 0.3934 0.0700 0.7498 0.3095 0.9018 0.0148 0.0536 0.9500 0.4073 0.6876 0.1992 0.7028 0.3751 0.1582 0.2395 0.9869 Columns 7 through 10 0.7699 0.5470 0.8715 0.8312 0.8296 0.4030 0.5076 0.9223 0.7061 0.1070 0.7888 0.3270 0.5953 0.7242 0.4730 0.8041 0.7529 0.6137 0.8288 0.5383 0.4967 0.7830 0.3225 0.4633 0.8651 0.5666 0.9761 0.8208 0.0680 0.8113 0.2782 0.9519 0.9685 0.5768 0.0728 0.0763 0.0988 0.9440 0.7512 0.7087 ans(:,:,4) = Columns 1 through 6 0.2349 0.3808 0.5741 0.7681 0.2982 0.5971 0.3989 0.6346 0.4869 0.2331 0.1584 0.2978 0.2681 0.3632 0.2622 0.5874 0.3613 0.1250 0.8325 0.4076 0.5796 0.4590 0.7416 0.3884 0.9954 0.3687 0.8783 0.8610 0.7059 0.8177 0.6498 0.4684 0.0610 0.6608 0.7009 0.9812 0.7040 0.5034 0.4409 0.3539 0.0062 0.8620 0.9323 0.9105 0.0843 0.3472 0.3743 0.0838 0.6877 0.2064 0.5632 0.2537 0.9015 0.3377 0.5684 0.3386 0.5393 0.9525 0.3183 0.2361 Columns 7 through 10 0.3178 0.7175 0.0667 0.1024 0.9844 0.1334 0.5415 0.9591 0.5483 0.4458 0.2817 0.1529 0.7493 0.5088 0.4809 0.1525 0.8419 0.5305 0.6849 0.1556 0.1669 0.8597 0.2083 0.0896 0.9031 0.6777 0.6082 0.4544 0.1051 0.8058 0.3262 0.6689 0.7451 0.5312 0.8808 0.8313 0.7294 0.9559 0.1334 0.7902 ans(:,:,5) = Columns 1 through 6 0.7127 0.6194 0.0522 0.0959 0.4243 0.2138 0.4726 0.6153 0.5712 0.0602 0.4900 0.6457 0.7086 0.1226 0.7477 0.8195 0.5835 0.3806 0.9581 0.1238 0.3202 0.7715 0.0833 0.1037 0.5058 0.2845 0.4929 0.1957 0.6602 0.3775 0.3051 0.7357 0.2217 0.8951 0.0523 0.2629 0.7898 0.4113 0.9393 0.6843 0.5568 0.2413 0.2364 0.8290 0.4823 0.6568 0.7120 0.6229 0.2343 0.9351 0.5400 0.9904 0.4879 0.5229 0.4647 0.3991 0.2211 0.0337 0.6176 0.4132 Columns 7 through 10 0.2178 0.7968 0.8094 0.1979 0.8586 0.1138 0.6088 0.6057 0.8610 0.1588 0.4799 0.8237 0.2839 0.3558 0.2684 0.8106 0.6154 0.8478 0.2581 0.8022 0.7795 0.5828 0.4810 0.7081 0.9548 0.5862 0.2273 0.8594 0.9196 0.9258 0.0486 0.7811 0.3848 0.5751 0.1692 0.2038 0.1626 0.0100 0.2584 0.9933 ans(:,:,6) = Columns 1 through 6 0.0936 0.6065 0.6107 0.9591 0.4009 0.4044 0.6506 0.7146 0.7038 0.7502 0.9950 0.3012 0.2152 0.4015 0.3833 0.9810 0.2610 0.9506 0.2439 0.8587 0.7287 0.2335 0.6653 0.4606 0.3397 0.9205 0.8873 0.0962 0.9643 0.2876 0.1979 0.7508 0.0558 0.3846 0.6712 0.0846 0.5068 0.2856 0.1382 0.5003 0.2992 0.5822 0.9508 0.7968 0.8631 0.5703 0.5311 0.1531 0.3946 0.1428 0.4217 0.9766 0.0015 0.0731 0.5845 0.5046 0.4113 0.4929 0.8838 0.5806 Columns 7 through 10 0.2870 0.9189 0.5179 0.9668 0.3619 0.6025 0.2457 0.6192 0.7248 0.7021 0.2975 0.1653 0.8583 0.7437 0.6505 0.8262 0.3479 0.3851 0.8914 0.6557 0.9617 0.2515 0.8611 0.5465 0.9536 0.0368 0.2099 0.2513 0.2060 0.4721 0.3991 0.0402 0.7682 0.6451 0.8879 0.2334 0.6155 0.2790 0.2565 0.3611 ans(:,:,7) = Columns 1 through 6 0.6335 0.8757 0.7635 0.2260 0.6917 0.5437 0.9861 0.6352 0.0489 0.3610 0.8805 0.3146 0.2072 0.0973 0.7259 0.3246 0.9245 0.3820 0.7571 0.9084 0.7013 0.0836 0.0813 0.7915 0.8863 0.0350 0.4589 0.5127 0.4827 0.8392 0.4722 0.0397 0.5823 0.8329 0.1283 0.6802 0.1589 0.9886 0.3391 0.9046 0.2529 0.4169 0.8109 0.6862 0.1706 0.7236 0.8840 0.6429 0.4765 0.3767 0.3992 0.3830 0.1963 0.2141 0.1163 0.5043 0.9198 0.2980 0.1214 0.6173 Columns 7 through 10 0.6752 0.8448 0.5463 0.9829 0.6010 0.8165 0.6366 0.7096 0.3463 0.8462 0.5709 0.1754 0.3644 0.3702 0.9271 0.8583 0.1715 0.3832 0.8638 0.9094 0.7954 0.8613 0.1698 0.9617 0.4927 0.4639 0.1787 0.5706 0.3546 0.5705 0.2435 0.5629 0.7751 0.6953 0.7518 0.1767 0.2368 0.9609 0.1991 0.5137 ans(:,:,8) = Columns 1 through 6 0.5485 0.6022 0.1519 0.4255 0.2915 0.1190 0.1653 0.3619 0.3807 0.4043 0.1884 0.9265 0.4939 0.1349 0.8210 0.4003 0.0229 0.5936 0.5351 0.9138 0.1714 0.1119 0.4494 0.8836 0.1988 0.6406 0.3300 0.4243 0.2436 0.4245 0.6232 0.6588 0.9665 0.6135 0.8687 0.6073 0.0263 0.6753 0.8063 0.9881 0.5286 0.0708 0.3188 0.7446 0.2222 0.2199 0.9141 0.9248 0.5330 0.8422 0.9998 0.3541 0.9739 0.6421 0.3268 0.5167 0.0637 0.2662 0.5854 0.1045 Columns 7 through 10 0.7002 0.6306 0.7203 0.6539 0.3958 0.9855 0.6788 0.6577 0.0849 0.6343 0.2128 0.1610 0.2145 0.6005 0.0816 0.4324 0.2488 0.9092 0.2745 0.5051 0.2267 0.5708 0.8675 0.3753 0.7030 0.3354 0.5594 0.4804 0.7542 0.9571 0.4646 0.3424 0.5473 0.4399 0.4303 0.7771 0.5535 0.6015 0.7740 0.3839 ans(:,:,9) = Columns 1 through 6 0.7116 0.0219 0.9095 0.7663 0.7293 0.4752 0.4809 0.8083 0.0579 0.7513 0.8598 0.8053 0.7292 0.1792 0.4368 0.1389 0.6270 0.5308 0.9376 0.1654 0.5723 0.3493 0.1806 0.2273 0.5173 0.1816 0.5651 0.1513 0.5733 0.7095 0.9031 0.6914 0.8238 0.4967 0.1636 0.1486 0.2182 0.2138 0.1261 0.8087 0.9061 0.6581 0.8732 0.2981 0.3001 0.6329 0.0773 0.6340 0.0827 0.7683 0.0021 0.6884 0.3385 0.2293 0.4654 0.5012 0.9511 0.6396 0.5806 0.1822 Columns 7 through 10 0.1664 0.8623 0.0713 0.7462 0.1496 0.8964 0.4891 0.1175 0.2027 0.1890 0.8499 0.5090 0.9550 0.6607 0.9970 0.1688 0.0159 0.9412 0.0044 0.8311 0.9575 0.9757 0.5426 0.9280 0.0257 0.1079 0.8613 0.1695 0.9711 0.1789 0.9091 0.8837 0.2976 0.7466 0.8454 0.3879 0.5251 0.0495 0.8789 0.3826 ans(:,:,10) = Columns 1 through 6 0.2715 0.8534 0.7858 0.5223 0.4429 0.8110 0.8679 0.3981 0.9226 0.3974 0.0530 0.1387 0.7415 0.1155 0.4923 0.4791 0.0878 0.8819 0.4479 0.0803 0.8340 0.9939 0.7980 0.9236 0.7096 0.3...
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