aoc/21/lib/days/day1.ex

18 lines
414 B
Elixir
Raw Normal View History

2023-04-17 18:18:20 +00:00
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