*power set of S*- namely, the set of all subsets of S. In our case, the power set of S is: {}, {a}, {b}, {c}, {a,c}, {a,b}, {b,c}, {a,b,c} So, given the set S as a vector in C++ I need to generate another vector - the power set. Fortunately, arithmetic in binary base gives us a very nice way to enumerate the subsets. Given a set size N, consider the binary representation of the numbers 0..N-1: 000, 001, 010, 011, 100, 101, 110, 111 If we think of 0 as "not included" and 1 as "included" we get exactly the power set. So, in C++ it's a simple matter of looping all the numbers between 0 and N-1, and for each one check the inclusion of each set member - if the bit at place X is set, the Xth element is in the next set, etc.

# application of combinations

For comments, please send me an email, or reach out on on Twitter.