Finding k-length subset of n elements using bitwise hack