I need to find all possible combinations of a given string, from a minimum length to a maximum length.
interface allCombos(string: String, min: Number, max:Number): Array {}
So if my input string is ‘abcde’, and my minimum length is 3, I want the result to be:
For length 3:
[‘abc’, ‘abd’, ‘abe’, ‘acd’, ..., ‘bcd’, ‘bce’, ..., ‘eda’, ...]
Concatenated with length 4:
[‘abcd’, ‘abdc’, ‘acdb’, ‘acbd’, …etc]
Concatenated with all possible combinations with length up to the max parameter. Which shouldn't be higher than the input word length.
I started thinking that all possible combinations would be ∑(3! + 4! + … + n!). But then I saw I'm wrong because for every length subset, there are many combinations for the whole world (for example 3-length combinations of a 6 letter string).
Can the community help me with this problem?
The solution can either be in JavaScript, Python or even pseudo code.
Edit
For knowledge's sake. Could anyone answer me, the formula that describes the result size in this case? I know its not ∑(3! + 4! + … + n!).