12 lines
336 B
Haskell
12 lines
336 B
Haskell
import Data.Bits ((.&.))
|
|
import Data.Char (ord)
|
|
import Data.List (foldl')
|
|
import Data.List.Split (splitOn)
|
|
|
|
getHash :: String -> Int
|
|
getHash = foldl' (\acc x -> (acc + ord x) * 17 .&. 255) 0
|
|
|
|
main :: IO ()
|
|
main = print . sum . map getHash . splitOn "," . concat . lines
|
|
=<< readFile "data.txt"
|