Cody

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

Solution 284377

Submitted on 18 Jul 2013 by tom
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));

k = 1 kk = 5 k = 1 2 kk = 3 6 k = 1 2 3 kk = 2 4 7

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

k = 1 kk = 2 k = 1 2 kk = 2 3

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

k = 1 kk = 4 k = 1 2 kk = 3 5

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

k = 1 kk = 5 k = 1 2 kk = 2 6

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

k = 1 kk = 10 k = 1 2 kk = 8 11 k = 1 2 3 kk = 8 9 12 k = 1 2 3 4 kk = 2 9 10 13 k = 1 2 3 4 5 kk = 2 3 10 11 14 k = 1 2 3 4 5 6 kk = 2 3 4 11 12 15 k = 1 2 3 4 5 6 7 kk = 2 3 4 5 12 13 16 k = 1 2 3 4 5 6 7 8 kk = 2 3 4 5 6 13 14 17 k = 1 2 3 4 5 6 7 8 9 kk = 2 3 4 5 6 7 14 15 18 k = 1 2 3 4 5 6 7 8 9 10 kk = 2 3 4 5 6 7 8 15 16 19 k = 1 2 3 4 5 6 7 8 9 10 11 kk = 2 3 4 5 6 7 8 9 16 17 20 k = 1 2 3 4 5 6 7 8 9 10 11 12 kk = 2 3 4 5 6 7 8 9 10 17 18 21 k = 1 2 3 4 5 6 7 8 9 10 11 12 13 kk = 2 3 4 5 6 7 8 9 10 11 18 19 22 k = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 kk = 2 3 4 5 6 7 8 9 10 11 12 19 20 23 k = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 kk = 2 3 4 5 6 7 8 9 10 11 12 13 20 21 24 k = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 kk = 2 3 4 5 6 7 8 9 10 11 12 13 14 21 22 25

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!