On Sun, Apr 22, 2012 at 7:55 PM, Terry Reedy <tjreedy@udel.edu> wrote:
On 4/22/2012 9:07 PM, Nestor wrote: <snip>
Have the function ArrayAddition(arr) take the array of numbers stored in arr and print true if any combination of numbers in the array can be added up to equal the largest number in the array, otherwise print false. For example: if arr contains [4, 6, 23, 10, 1, 3] the output should print true because 4 + 6 + 10 + 3 = 23. The array will not be empty, will not contain all the same elements, and may contain negative numbers.
Since the order of the numbers is arbitrary and irrelevant to the problem, it should be formulated in term of a set of numbers.
Er, multiplicity still matters, so it should be a multiset/bag. One possible representation thereof would be a list... Cheers, Chris