问题
I am looking for help with an algorithm that will generate all the possible combinations of n-random letters in decreasing length. For example, the array of 'a','b','c' should generate:
abc acb bac bca cab cba ab ac ba bc ca cb a b c
where letters cannot repeat themselves once used
回答1:
"Permutation with decresing length" is basically just a loop of standard permutation task.:
- you are given a set of n letters
- take each letter and add it to the output
- take all possible pairs of letters and add them to the output
- take all possible triplets of letters and add them to the output
- ... do until you reach N
来源:https://stackoverflow.com/questions/27561212/algorithm-to-generate-all-combinations-of-a-string-with-length-n-to-1