I have my homework assignment and I have no idea how to start with the code for this kind of problem.
Let say I have an integer array with consist of n elements,
[A][B][C][D][E] (We have 5 elements for example)
I want to list out all the sum of possibility such that I want to print out the
sum of all combination (ABCDE, ABCD, ABCE, ACDE, BCDE, ABC, ABD, ABE, ACE, ADE, BDE, CDE, AB, AC, AD, AE, BC, BD, BE, CD, CE, DE, A, B, C, D and E)
Another example would be 4 elements in an array ([A][B][C][D])
I want to list all sum of combination of (ABCD, ABC, ABD, ACD, BCD, AB, AC, AD, BC, BD, CD, A, B, C and D).
Well, here’s a simple rule to follow:
The set of all combinations of “ABCDE” is composed of those combinations which contain (and thus start with) “A” and those which don’t contain “A”. In both cases, all combinations of “BCDE” can occur. Of course, combinations of “BCDE” can be treated in the same way.