I stick with mappings to prime numbers. Haskell, without considerations of performance:
primes = sieve [2..]
where sieve (p:xs) = p : sieve [x | x <- xs, x `mod` p /= 0]
charToPrime c = lookup c $ zip ['a'..'z'] primes
eval word = product <$> sequence (map (charToPrime . toLower) word)
isAnagram word1 word2 = eval word1 == eval word2
lookup and charToPrime return a Maybe value, without catching the eye. Umlauts or digits result in a Nothing value for the character and in a product of 1 for the word. The handling of those cases could be improved.
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.