20 lines
449 B
Haskell
20 lines
449 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 s = only $ take half s `intersect` drop half s
|
|
where
|
|
halfFloat = fromIntegral (length s) / 2
|
|
half = round halfFloat
|
|
|
|
main = interact $
|
|
show . sum
|
|
. map (getCharPriority . findDuplicate)
|
|
. lines |