The general idea would be to list all possible permutations first, then filter them to get the combinations.
According to the requirements I gave in the first post, the possible numbers of permutations and combinations are: (n is the number of characters in the variable)
For combinations: Σ(n)=2(n-1)+2(1)+2(2)+2(3)+......+2(n) Note: in this formula, the values in () are exponents of 2.
That is: Σ(n)=2(n)-1 Note: in this formula, the values in () are exponents of 2.
For permutations: Σ(n)=n+
n*(n-1)+
n*(n-1)*(n-2)+
n*(n-1)*(n-2)*(n-3)+
n*(n-1)*(n-2)*(n-3)*(n-4)+
n*(n-1)*(n-2)*(n-3)*(n-4)*(n-5)+
......
n*(n-1)*(n-2)*(n-3)*(n-4)*(n-5)*......*3+
n*(n-1)*(n-2)*(n-3)*(n-4)*(n-5)*......*3*2+
n*(n-1)*(n-2)*(n-3)*(n-4)*(n-5)*......*3*2*1
When there are only four Chinese characters, that is, n=4, then the number of permutations is 64, and the number of combinations is 15. As n increases, the number of combinations grows algebraically, while the number of permutations grows geometrically.
For example, when n=10, the number of combinations is 1023, while the number of permutations is 9183700, an astronomical figure close to ten million. Then having to filter through 9183700 permutation cases to get the 1023 valid combination cases is a pretty terrifying thing...
So I had this idea: is it possible not to use the “permute first, then filter” method?
[ Last edited by Hanyeguxing on 2009-7-5 at 08:15 ]