Android Question Need help looping through string

tsteward

Well-Known Member
Licensed User
I have a string
dim mystring(someqty) as string

Length of mystring is variable and may look like this
mystring(0) = 24311
mystring(1) = 327--

Each item will be the same length but length may vary each run.
string(0) will always contain full set of characters
following string my contain '-' which is to be ignored.

Now I want to build a list of all possible permutations without mixing columns.
result:
24311
24711
22311
22711
34311
34711
32311
32711

I know I can do this but just cant get my head around it
Any help appreciated.
 

Troberg

Well-Known Member
Licensed User
You'll probably have to do it recursively, first creating all options for the first digit, then for each of them, all possible options for the second digit and so on.

Be aware, though, that the number of possible permutations will escalate very quickly. Assuming no "-" in the numbers, it's be something along the lines of NumberOfItems^LengthOfItems. In other words, chances are that the stack will burst like something that bursts violently.

None of this removes duplicates, by the way...
 
Top