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 isSolutionTriple . triples . 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
|
|
|
triples = sequence . replicate 3
|
2022-09-21 09:19:52 -04:00
|
|
|
|
2022-09-21 09:19:52 -04:00
|
|
|
isSolutionTriple = (2020 ==) . sum
|
2022-09-21 09:19:52 -04:00
|
|
|
|
2022-09-21 09:19:52 -04:00
|
|
|
findJust f = fromJust . find f
|