I have to get every possible combination of given string. The string I get can be of various sizes but always contains only 1 and 0.
For example, Combinations I want to get with "101" as the input :
"000" "001" "010" "100" "110" "101" "011" "111".
I tried using std::next_permutation (c++20), I'm getting close but this not exactly not what I want.
The final goal is to store every combination inside a string vector.
Below is what I tried with next_permutation
// I'm not using *using namespace std* no need to mention it
std::vector<std::string> generate_all_combinations(std::string base)
{
std::vector<std::string> combinations;
do {
combinations.push_back(base);
} while (std::next_permutation(base.begin(), base.end()));
return combinations;
}
When I print the vector's content I have : "011" "101" "110".
The base strings "000" and "111" are not a problem I can generate those pretty easily. But I'm still lacking other combinations like "001" "010" "100".