Cody

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

Solution 1219408

Submitted on 24 Jun 2017 by Augusto Mazzei
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));

SU = 14 x = 1 2 3 4 5 6 7 x = 1 2 3 4 5 6 7 r = 1 c = 1 c = 6 c = 7

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

SU = 6 x = 2 2 2 2 2 2 x = 2 2 2 2 2 2 r = 1 c = 1 2 3 4 5 6 c = 2 3 4 5 6 c = 3 4 5 6

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

SU = 10 x = 2 5 4 5 4 x = 2 4 4 5 5 r = 2 c = 3 5 c = 1 c = 5

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

SU = 11 x = 1 3 1 1 9 7 x = 1 1 1 3 7 9 r = 3 c = 1 3 4 c = 3 4 c = 5

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

SU = 530 x = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 x = 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 r = 16 c = 16 c = 11 c = 4 c = 15 c = 2 c = 18 c = 7 c = 3 c = 1 c = 24 c = 17 c = 21 c = 23