23 lines
568 B
Haskell
23 lines
568 B
Haskell
|
import Data.Char
|
||
|
import Data.List.Split
|
||
|
|
||
|
|
||
|
inAll :: [String] -> [Char]
|
||
|
inAll [first,second,third] = do
|
||
|
eachChar <- first
|
||
|
if (eachChar `elem` second && eachChar `elem` third) then return eachChar 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 . inAll ) $ chunksOf 3 $ lines input
|
||
|
--print $map ( inAll ) $ chunksOf 3 $ lines input
|