Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.List(sort)
- import Data.Char(ord)
- main = readFile "names.txt" >>= print . result
- result cs = sum
- $ zipWith
- (\n w -> n * avalue w) [1..] (sort words)
- where words = (read $ "[" ++ cs ++ "]")::[String]
- avalue = foldr
- (\c acc-> ord c - ord 'A' + 1 + acc)
- 0
Add Comment
Please, Sign In to add comment