Possible Duplicate:
Generate list of all possible permutations of a string
I need to work on a small algorithm project where I need to be able to list and write to a text file the possible combination of a given set of characters based on a given limit.
For example, if I enter the characters "a", "b", and "c" and set the limit to 3 the possible output would be:
a
b
c
aa
bb
cc
ab
ac
ba
bc
ca
cb
...
aaa
bbb
ccc
...
...
abc
acb
bac
bca
cab
cba
Until all possible combinations have been devised.
Writing this to a text file is no problem with me. Having an algorithm that would write the combination is something that I am quite not good at.
Appreciate in .NET (C# or VB) codes.
Thanks.
PS
On a side note, I wonder how long it would take for an application to create a string combination of all possible keyboard characters and how big the file would get to be.
Updated: I should also show character combination from n characters to the implied limit..
n**bunique permutations ofnitems from a set of sizeb. (in particular, this tells you how many numbers n digits in base b can represent (e.g. 5 bits:2**5 == 32)). Even assuming ASCII (95 printable chars), there are 857,375 3-letter, 81,450,625 4-letter, (and so on) strings. This grows expotentially. And nowadaws, you have codepages with 256 chars or even Unicode. For many purposes, there are much cheaper solutions...