Improved project structure.

This commit is contained in:
2017-06-01 14:50:23 +02:00
parent 5e06b03248
commit 89f0d81598
25 changed files with 2 additions and 0 deletions

15
haskell/e022.hs Normal file
View File

@@ -0,0 +1,15 @@
import Data.List
toScore :: Char -> Integer
toScore b = snd . head . dropWhile (\(c, i) -> c /= b) $ zip ['A'..'Z'] [1..26]
nameScore :: (Integer, String) -> Integer
nameScore (i, s) = i * (sum (map toScore s))
listScore :: [String] -> Integer
listScore = sum . map nameScore . zip [1..]
main = do
file <- readFile "22.txt"
let names = sort . read $ file :: [String]
putStrLn . show . listScore $ names