aoc2022/3-b-v2.hs

20 lines
456 B
Haskell

-- i found out that intersect exists so i redid day 3
import Data.Char
import Data.List
import GHC.Utils.Misc
getCharPriority c
| isLower c = fromEnum c - 96
| isUpper c = fromEnum c - 64 + 26
| otherwise = undefined
findDuplicate :: [String] -> Char
findDuplicate [l1, l2, l3] = only $ l1 `intersect` l2 `intersect` l3
findDuplicate _ = undefined
main = interact $
show . sum
. map (getCharPriority . findDuplicate)
. chunkList 3
. lines