Day 1
Preparation
Mix.install([:kino])
Part 1
example_input = """
199
200
208
210
200
207
240
269
260
263
"""
input = Kino.Input.textarea("Please input your file:", default: example_input)
input
|> Kino.Input.read()
|> String.split("\n", trim: true)
|> Enum.map(&String.to_integer/1)
|> Enum.chunk_every(2, 1, :discard)
|> Enum.filter(fn [left, right] -> right > left end)
|> Enum.count()
Part 2
input
|> Kino.Input.read()
|> String.split("\n", trim: true)
|> Enum.map(&String.to_integer/1)
|> Enum.chunk_every(3, 1, :discard)
|> Enum.chunk_every(2, 1, :discard)
|> Enum.filter(fn [left, right] -> Enum.sum(right) > Enum.sum(left) end)
|> Enum.count()