Gary Wessle wrote:
Hi
is there a function or lib in c++ which may already do this.
given {a,b,c}, give all the combinations which contain 2 letters,
would be {a,b}, {a,c}, {b,c}
thanks
Not in the standard library. Though you could make use of
std::next_permutation to achieve your result. If you want n choose k,
make a mask of length n with (n-k) 0s and k 1s: {0 0 0... 1 1 1}.
Repeatedly apply next_permutation to this mask and, for each such mask,
apply it to your array of values, keeping those values that match a 1 in
the mask.