I apologize if the motivation wasn't clear.
At a mathematical level, it's a problem of multiplying `N` polynomials, each of which has two terms:

`For N=2:
(a+b)*(c+d) = ac + ad + bc + bd
For N=3:
(a+b)*(c+d)*(e+f) = ace + acf + ade + adf +
+ bce + bcf + bde + bdf
`

What I was after was an explicit expression for
each of the

`2**N`
terms on the right-hand-side of these equations.

As for why one would want to do this beyond a homework
question, this problem arises in theories of
quantum computing, particularly in trying to
write an arbitrary state in terms of what's called the
computational basis for an N-qubit state.

Comment onRe^2: Obtaining terms in an expansionDownloadCode