aoc2022/3-b-v2.hs

20 lines
456 B
Haskell
Raw Permalink Normal View History

2022-12-04 07:11:45 +01:00
-- 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)
2022-12-04 07:23:30 +01:00
. chunkList 3
2022-12-04 07:11:45 +01:00
. lines