I'm writing a program to match anagrams in order to practice coding. One way I want to try this is to assign values to letters such that adding up the letters in the individual words creates a unique value. This will allow me to match words without worrying about the order of the letters. I think I can do this by playing around with different approaches but I really want to know how to do this mathematically. Assume all letters will be uppercase (so 26 total letters) and, for this example, I don't want to worry about any kind of character other than A-Z.
2026-04-09 09:25:48.1775726748
How to assign values to letters to create unique values per word when all letters are added together?
1.5k Views Asked by Bumbble Comm https://math.techqa.club/user/bumbble-comm/detail At
2
This will require large numbers, as you get $26^n$ possibilities for an $n$ lettered word. To make a unique number for each word, have the letters numbered 0 to n-1, and find the sum
unique word number=$\sum_{i=0}^{n-1}$$26^i$*letter value of letter i(0 to 25, not 1 to 26)
This will make every number unique for every word, even if they end up large.