Velocity Reviews > Identify letter combinations where order is not important?

Identify letter combinations where order is not important?

D r . P r o z a c
Guest
Posts: n/a

 10-19-2003
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.

--
Peter.

Simon Biber
Guest
Posts: n/a

 10-19-2003
" D r . P r o z a c" <(E-Mail Removed)> 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.

Robert Stankowic
Guest
Posts: n/a

 10-20-2003

" D r . P r o z a c" <(E-Mail Removed)> schrieb im Newsbeitrag
news:bmu3me\$mi6\$(E-Mail Removed)...
> 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_SEQUENC E];
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

Micah Cowan
Guest
Posts: n/a

 10-20-2003
" D r . P r o z a c" <(E-Mail Removed)> 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