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

Created by Ned Gulley in Community

Given a vector x, return the indices to elements that will sum to exactly half of the sum of all elements.


 Input  x  = [1 2 3 4 5 6 7]
 Output xi = [1 6 7]


 sum(x) = 28
 sum(x([1 6 7])) = 14

The answer is not necessarily unique and the order is unimportant. We will just test to make sure that sum(x)/2 is sum(x(xi))

Solution Stats

24.74% Correct | 75.26% Incorrect
Last solution submitted on Mar 26, 2019

Problem Comments

Solution Comments

Recent Solvers259

Suggested Problems

More from this Author63


Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!