I need to assign unique integer values to words in a dictionary that have the same alphabets, for example 'act' and 'cat' should have the same integer value. Would just adding the ascii values of the letters be sufficient?
I need to assign unique integer values to words in a dictionary that have the same alphabets, for example 'act' and 'cat' should have the same integer value. Would just adding the ascii values of the letters be sufficient?
No, because two different words may have the same sum.
You could take each word, sort its letters and then compare them. If both sorted-letter words are equal, assign then the same integer value.
For example:
"listen" is "eilnst" sorted
"silent" is also "eilnst" sorted
Therefore, "listen" and "silent" should be assigned the same value
Devoted my life to programming...