You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

9 lines
351 B
Haskell

main = do
contents <- readFile "day1.txt"
let xs = map read $ lines contents
let [(i, j, k)] = [(i, j, k) | i <- [0..(length xs)-1],
j <- [0..i],
k <- [0..j],
(xs !! i) + (xs !! j) + (xs !! k) == 2020]
print $ (xs !! i) * (xs !! j) * (xs !! k)