Guest User

Untitled

a guest
Jan 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. import Data.List(sort)
  2. import Data.Char(ord)
  3.  
  4. main = readFile "names.txt" >>= print . result
  5.  
  6. result cs = sum
  7. $ zipWith
  8. (\n w -> n * avalue w) [1..] (sort words)
  9. where words = (read $ "[" ++ cs ++ "]")::[String]
  10. avalue = foldr
  11. (\c acc-> ord c - ord 'A' + 1 + acc)
  12. 0
Add Comment
Please, Sign In to add comment