aoc/21/lib/days/day1.ex
2023-12-04 10:25:33 +01:00

17 lines
414 B
Elixir

defmodule AOC.Day1 do
def part1 do
AOC.Util.input_integers(1, 1)
|> Enum.chunk_every(2, 1, :discard)
|> Enum.map(fn [x, y] -> y > x end)
|> Enum.count(& &1)
end
def part2 do
AOC.Util.input_integers(1, 1)
|> Enum.chunk_every(3, 1, :discard)
|> Enum.map(&Enum.sum/1)
|> Enum.chunk_every(2, 1, :discard)
|> Enum.map(fn [x, y] -> y > x end)
|> Enum.count(& &1)
end
end