#Loop keep getting stuck when generating combinations
4 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
!format
!code
combinations = {"word", "random", "test"}
total_combinations = 27
generate_combinations(combinations, "", total_combinations, 0);
void Generate::generate_combinations(std::vector<std::string> words,
std::string currentCombination,
int maximum_combinations,
int current) {
if (current <= words.size()) {
std::cout << currentCombination << std::endl;
}
for (std::string word : words) {
generate_combinations(words, currentCombination + word,
maximum_combinations, current + 1);
}
}
If you want the whole code, tell me