19 lines
371 B
Elixir
19 lines
371 B
Elixir
defmodule AOC.Day1 do
|
|
def part1 do
|
|
l = AOC.Util.input_integers(1, 1)
|
|
[x, y] = Enum.filter(l, &((2020 - &1) in l))
|
|
x * y
|
|
end
|
|
|
|
def find_three([h | tl]) do
|
|
case Enum.filter(tl, &((2020 - h - &1) in tl)) do
|
|
[x, y] -> h * x * y
|
|
_ -> find_three(tl)
|
|
end
|
|
end
|
|
|
|
def part2 do
|
|
AOC.Util.input_integers(1, 1)
|
|
|> find_three()
|
|
end
|
|
end
|