2022-09-21 09:19:52 -04:00
|
|
|
#!/usr/bin/env runghc
|
|
|
|
|
|
|
|
import Data.List
|
|
|
|
import Data.Maybe
|
|
|
|
|
2022-09-21 09:19:52 -04:00
|
|
|
main = interact findSolution
|
2022-09-21 09:19:52 -04:00
|
|
|
|
2022-09-21 09:19:52 -04:00
|
|
|
findSolution = show . product . findJust isSolutionPair . pairs . parseInput
|
2022-09-21 09:19:52 -04:00
|
|
|
|
2022-09-21 09:19:52 -04:00
|
|
|
parseInput = map read . lines
|
2022-09-21 09:19:52 -04:00
|
|
|
|
2022-09-21 09:19:52 -04:00
|
|
|
pairs = sequence . replicate 2
|
2022-09-21 09:19:52 -04:00
|
|
|
|
2022-09-21 09:19:52 -04:00
|
|
|
isSolutionPair = (2020 ==) . sum
|
2022-09-21 09:19:52 -04:00
|
|
|
|
2022-09-21 09:19:52 -04:00
|
|
|
findJust f = fromJust . find f
|