Created
February 6, 2019 16:01
-
-
Save Adspartan/09403bde7820f116f54715fc9ffc5654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
std::vector<std::string> recursion(std::vector<char> chars, int min_rec, int max_rec) | |
{ | |
std::vector<std::string> results; | |
if (min_rec <= 1) | |
{ | |
for (char c : chars) | |
{ | |
results.push_back(std::string(1, c)); | |
} | |
} | |
if (max_rec == 1) | |
{ | |
return results; | |
} | |
auto rec = recursion(chars, min_rec - 1, max_rec - 1); | |
for (auto c : chars) | |
{ | |
for (auto s2 : rec) | |
{ | |
results.push_back(c + s2); | |
} | |
} | |
return results; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment