I am doing some research where I have a List containing numbers. For example
{5,10,98,22,13,15}
What is a fast algorithm to calculate all possible sums and differences from these? Eventually I will want to do the same thing for a list of 400+ numbers.
Some examples in the final set
index0+index1=5+10=15
index0+index3+index4=5+22+13=40
index0+index2-index5=5+98-15=88
index3-index4=22-13=9
What I am thinking now is 3 for loops. One to move through the array, one to keep track of how many numbers to skip, and one for the number of skips. But that seems slow.
Ahh I guess my answer is unsolvable bc of P=NP. I see from here: https://en.wikipedia.org/wiki/Subset_sum_problem