Android Question Need help looping through string

Discussion in 'Android Questions' started by tsteward, Feb 6, 2015.

  1. tsteward

    tsteward Active 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.

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

    Peter Simpson Expert Licensed User

    I've probably got your question completely wrong but...
        Dim Counter() As String = Array As String(1234567890)

    For i = 0 To Counter.Length - 1
    You can also use Regex.Split("-", i)
    Last edited: Feb 6, 2015
  3. Troberg

    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...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice