Like Tree3Likes
  • 3 Post By GReaper

Unique integer values for words

This is a discussion on Unique integer values for words within the C++ Programming forums, part of the General Programming Boards category; I need to assign unique integer values to words in a dictionary that have the same alphabets, for example 'act' ...

  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
    1,625
    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
    Elkvis, stahta01 and DRK like this.
    Devoted my life to programming...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 11-04-2012, 11:26 AM
  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, 10:19 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21