aboutsummaryrefslogtreecommitdiff
path: root/elixir/aoc/01/main.exs
blob: e46450db8efd7d2b4f194eac3f56df40cb1de236 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
{ _, data } = File.read "input"

xs = String.split(data, "\n\n")
|> Enum.map(fn x ->
	String.split(x)
	|> Enum.reduce(0, &(&2 + elem(Integer.parse(&1), 0)))
end)

IO.puts Enum.max(xs)
IO.puts Enum.sort(xs, :desc)
|> Enum.take(3)
|> Enum.sum