Thread: Unique integer values for words

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    6

    Unique integer values for words

    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?

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Quote Originally Posted by nwasiq View Post
    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...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 11-04-2012, 12:26 PM
  2. String (hostname) to unique integer.
    By looza in forum C Programming
    Replies: 4
    Last Post: 03-30-2011, 02:48 PM
  3. Making unique integer ID# from a string.
    By Ayreon in forum C Programming
    Replies: 18
    Last Post: 03-09-2009, 06:26 PM
  4. using structures to assign unique values to words?
    By coreyt1111 in forum C++ Programming
    Replies: 3
    Last Post: 11-29-2006, 11:19 AM