Cody

# Problem 660. Find a subset that divides the vector into equal halves

Solution 1632974

Submitted on 25 Sep 2018 by Be Matlabi
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
x = [1 2 3 4 5 6 7]; xi = split_it(x); assert(isequal(sum(x(xi)),sum(x)/2));

b = 1×0 empty double row vector b = 15 24 28 29 xi = 1 0 0 xi = 1 6 0 xi = 1 6 7

2   Pass
x = [2 2 2 2 2 2]; xi = split_it(x); assert(isequal(sum(x(xi)),sum(x)/2));

b = 1×0 empty double row vector b = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 xi = 1 0 0 xi = 1 1 0 xi = 1 1 1

3   Pass
x = [2 5 4 5 4]; xi = split_it(x); assert(isequal(sum(x(xi)),sum(x)/2));

b = 6 xi = 2 0 xi = 2 2

4   Pass
x = [1 3 1 1 9 7]; xi = split_it(x); assert(isequal(sum(x(xi)),sum(x)/2));

b = 1×0 empty double row vector b = 4 6 8 13 15 17 xi = 1 0 0 xi = 1 2 0 xi = 1 2 6

5   Pass
x = primes(100); xi = split_it(x); assert(isequal(sum(x(xi)),sum(x)/2));

b = 1×0 empty double row vector b = 1×0 empty double row vector b = 1×0 empty double row vector b = 1×0 empty double row vector b = 1×0 empty double row vector b = 1×0 empty double row vector b = Columns 1 through 15 590467 591113 591133 591138 591191 591216 591235 760088 761468 761656 761739 761782 874653 876367 877286 Columns 16 through 30 877727 877747 877752 877952 877961 878035 878039 878044 878058 878066 878078 952172 953882 954784 955262 Columns 31 through 45 955271 955400 955455 955530 955554 955581 999557 1002559 1004249 1004269 1004274 1005188 1005197 1005579 1005629 Columns 46 through 60 1005654 1005859 1005863 1005868 1005921 1005938 1005946 1005963 1005965 1034378 1036088 1036097 1036940 1036995 1037473 Columns 61 through 75 1037477 1037482 1037611 1037658 1037682 1037727 1037765 1045824 1050823 1053805 1053825 1053830 1055465 1055515 1055540 Columns 76 through 90 1056459 1056463 1056468 1056725 1056845 1056886 1056900 1056904 1056917 1057109 1057126 1057134 1057178 1057192 1057207 Columns 91 through 105 1057209 1057234 1057240 1062241 1065260 1065269 1066975 1066979 1066984 1067702 1067827 1067874 1067898 1068339 1068356 Columns 106 through 120 1068364 1068445 1068490 1068531 1068569 1068636 1068672 1071694 1071698 1071703 1072962 1073388 1073405 1073413 1074136 Columns 121 through 135 1074208 1074253 1074294 1074332 1074718 1074759 1074773 1074788 1074790 1074879 1074910 1074987 1075062 1075079 1075932 Columns 136 through 150 1076393 1076640 1076751 1076765 1076769 1076806 1076816 1076824 1076850 1077312 1077688 1077729 1077743 1077758 1077760 Columns 151 through 165 1078011 1078025 1078029 1078136 1078146 1078154 1078178 1078187 1078199 1078201 1078230 1078307 1078345 1078359 1078387 Columns 166 through 180 1078400 1078429 1078435 1078468 1078470 1078490 1078538 1079013 1079027 1079031 1079278 1079351 1079389 1079403 1079431 Columns 181 through 195 1079444 1079473 1079479 1079726 1079736 1079744 1079816 1079838 1079847 1079859 1079861 1079900 1079902 1079914 1079920 Columns 196 through 210 1079937 1080047 1080060 1080100 1080102 1080122 1080183 1080191 1080226 1080253 1080479 1080517 1080531 1080629 1080642 Columns 211 through 225 1080682 1080684 1080704 1080785 1080811 1080813 1080862 1080903 1080915 1080973 1080984 1081166 1081168 1081188 1081221 Columns 226 through 230 1081229 1081264 1081297 1081347 1081418 xi = 2 0 0 0 0 0 0 0 xi = 2 13 0 0 0 0 0 0 xi = 2 13 19 0 0 0 0 0 xi = 2 13 19 20 0 0 0 0 xi = 2 13 19 20 22 0 0 0 xi = 2 13 19 20 22 23 0 0 xi = 2 13 19 20 22 23 24 0 xi = 2 13 19 20 22 23 24 25