import Data.Char splitlist :: [a] -> ([a],[a]) splitlist list = (take n list,drop n list) where n = (length list) `div` 2 inBoth :: (Eq a) => ([a],[a]) -> [a] inBoth (first,second) = do inFirst <- first if (inFirst `elem` second) then return inFirst else [] toPriority :: Char -> Int toPriority char = ordNum - (substract ordNum) where ordNum = (ord char) substract n | n < 97 = 38 | otherwise = 96 main = do input <- readFile "three-input.txt" print $sum $ map (toPriority . head . inBoth . splitlist ) $ lines input