Problem Array Adder Balances - RobAllan27/CodingProblems GitHub Wiki

Overview

Array part adder takes an array integers and return true or false if the array can be broken into 2 sets such that

  • some members are added to form a sum
  • remaining members are added and form the same sum

The added members do not have to be contiguous

No items are ommitted

Approach

Approach is to work out the lenght of the array

  • The get binary numbers as 1 or 0s to show the combinations - 0 and 1 set effectively.
  • Then, choose members for the array and add them to a left and right set depending on the 0 or 1.

Possible tests and examples

	True - {1,2,3}
	False - {0,2,3}
	False - {0,0,3}
	True - {1,1,2}
	True - 0,0}
	True - {1,1}
	False - {10,10,20,30,40,120}
	False - {10,10,20,30,40,120,121,122}
	True - {1,1}
	True - {10,10,10,20,30,40,120}

Package

package arraypartsaddtosum