Day 1: Sonar Sweep
Setup
Mix.install([
{:kino, "~> 0.4.1"}
])
:ok
Input
input = Kino.Input.textarea("Input")
Part 1
Kino.Input.read(input)
|> String.split("\n", trim: true)
|> Enum.map(&String.to_integer(&1))
|> Enum.chunk_every(2, 1, :discard)
|> Enum.map(fn [x, y] -> y > x end)
|> Enum.count(fn x -> x end)
1754
Part 2
Kino.Input.read(input)
|> String.split("\n", trim: true)
|> Enum.map(&String.to_integer(&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(fn x -> x end)
1789