All possible combinations of a string

Discussion in 'C++' started by anjanesh, Dec 27, 2004.

  1. radams

    radams New Member

    Joined:
    May 6, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hate to tell you this but this code doesn't generate all possible combinations. Upon testing the code and converting it for java I have discovered that is duplicates combinations. I put in the word "abcd" and it generates the same "abcd" twice. It seems to work fine for 3 letter words. There is clearly a bug in the code.
     
  2. anjanesh

    anjanesh New Member

    Joined:
    Dec 25, 2004
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Freelance Developer
    Location:
    Nerul, Navi Mumbai, India
    Home Page:
    http://anjanesh.com
    I just ran this code in HTML + Javascript and this is what I got for abcd.
    Code:
    abcd
    abdc
    acbd
    acdb
    adbc
    adcb
    badc
    bacd
    bcda
    bcad
    bdca
    bdac
    cabd
    cadb
    cbad
    cbda
    cdab
    cdba
    dacb
    dabc
    dbca
    dbac
    dcba
    dcab
    There is just one occurance of abcd.
     

Share This Page

  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