Identify letter combinations where order is not important?

Discussion in 'C Programming' started by D r . P r o z a c, Oct 19, 2003.

  1. Hi,

    I want to identify combinations of letters (a-z)... to make the combination
    unique, but where the order of these letters is not important.

    For example:
    'er' and 're' should have the same unique identity.

    --
    Thanks in advance,
    Peter.
    D r . P r o z a c, Oct 19, 2003
    #1
    1. Advertising

  2. D r .  P r o z a c

    Simon Biber Guest

    " D r . P r o z a c" <> wrote:
    > Hi,
    >
    > I want to identify combinations of letters (a-z)... to make the combination
    > unique, but where the order of these letters is not important.
    >
    > For example:
    > 'er' and 're' should have the same unique identity.


    This is not a question about the C programming language. Either rephrase it
    or find somewhere more appropriate. If you can come up with a more complete
    description of what you want your program to do you could post to
    comp.programming

    --
    Simon.
    Simon Biber, Oct 19, 2003
    #2
    1. Advertising

  3. " D r . P r o z a c" <> schrieb im Newsbeitrag
    news:bmu3me$mi6$...
    > Hi,
    >
    > I want to identify combinations of letters (a-z)... to make the

    combination
    > unique, but where the order of these letters is not important.
    >
    > For example:
    > 'er' and 're' should have the same unique identity.
    >


    If I don't misunderstand what you want to do...

    You could use an array of structs like in
    struct
    {
    char letters[SOME_SIZE_LARGE_ENOUGH_TO_HOLD_THE_LONGEST_SEQUENCE];
    unsigned long id;
    }[ENOUGH_TO_HOLD_ALL_PATTERNS] = {0};

    Now iterate through the structs, fill the letters member of the structs with
    your character sequences and qsort the letter arrays in _descending_ order
    (so the zeroes from the initialisation will remain at the end of the char
    arrays), then qsort the structs themselves, using the "letters" members as
    sort criteria.
    Finally you iterate through the array of structs again, assign values to the
    "id" members (starting with 0 and only incrementing if struct[n].letters
    compares unequal to the struct[n-1].letters, and you are done.

    HTH
    Robert
    Robert Stankowic, Oct 20, 2003
    #3
  4. D r .  P r o z a c

    Micah Cowan Guest

    " D r . P r o z a c" <> writes:

    > Hi,
    >
    > I want to identify combinations of letters (a-z)... to make the combination
    > unique, but where the order of these letters is not important.
    >
    > For example:
    > 'er' and 're' should have the same unique identity.


    Simply choose a consistent ordering and order the letters
    appropriately every time you encounter them: use the ordered
    version as the identity.

    -Micah
    Micah Cowan, Oct 20, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. vertigo

    big letter -> small letter

    vertigo, Jul 6, 2004, in forum: Python
    Replies:
    4
    Views:
    744
    Reinhold Birkenfeld
    Jul 6, 2004
  2. Tony Meyer

    RE: big letter -> small letter

    Tony Meyer, Jul 6, 2004, in forum: Python
    Replies:
    0
    Views:
    491
    Tony Meyer
    Jul 6, 2004
  3. Andrew McNamara

    Re: big letter -> small letter

    Andrew McNamara, Jul 6, 2004, in forum: Python
    Replies:
    2
    Views:
    739
    Scott David Daniels
    Jul 6, 2004
  4. Rich
    Replies:
    5
    Views:
    427
  5. Teme Rosi

    All possible letter combinations?

    Teme Rosi, Dec 11, 2008, in forum: Ruby
    Replies:
    3
    Views:
    203
    Martin Carpenter
    Dec 16, 2008
Loading...

Share This Page