#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2004
    Posts
    28
    Rep Power
    0

    generating combinations


    if i had this string "a,b,c,d,d"

    how could i write code so that i could find all the possible combinations of the letters in this string?
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    27
    Rep Power
    0
    hmm, I'm sure this isn't the best way, but what about mapping numbers to the letters, then generating random numbers (which could be turned into the letters) and saving each try in a TStringList or something, and maybe if it didn't get a new combo after 20 tries or so, it could be done. What do you guys think?
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    Originally Posted by room24
    if i had this string "a,b,c,d,d"

    how could i write code so that i could find all the possible combinations of the letters in this string?
    Are you maybe looking for permutation algorithms?
    Is this your homework?

    M.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2004
    Posts
    27
    Rep Power
    0
    Do you think my advice would actually work? And, if that helped you or anyone else, please consider answering this post: http://forums.devshed.com/t213544/s.html
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Oct 2000
    Location
    Back in the real world.
    Posts
    5,966
    Rep Power
    190
    Originally Posted by HappyDev
    Do you think my advice would actually work?
    It's a brute force approach, but using random numbers makes it very fragile and unreliable. Short: No, it would not work.

    M.

IMN logo majestic logo threadwatch logo seochat tools logo