Compute sums of all subsets of some words We have $16$ words of given length, let's say $W_1,...,W_{16}$ and  and i want to make an one dimensional matrice that will contain all the possible sums of $W_i$'s, for example:

$W_1,W_2,...,W_{16}$

$W_1+W_2,W_1+W_3,...,W_1+W_{16}$

$W_2+W_3,...,W_2+W_{16}$

and so on, all the by two sums...

then all the three sums

$W_1+W_2+W_3,...,W_1+W_2+W_{16}$

then all the four sums

until the sums which is all by sixteen  

$W_1+W_2+...+W_{16}$.

Is there a faster way for example, than using a triple $for$ to make all the possible by three sums and in general n fors to make all the by n sums?
If you think that there are much fewer than $2^{16} $ sums, you can try the following approach. Iteratively compute a sorted list of all partial sums of the first $k$ values.  Given this list for some $k$, add to all sums in the list $W_{k+1} $, and then merge the two lists like in Mergesort, removing duplicates. The total complexity should be asymptotic to the number of distinct partial sums.