Use Livebook to open this notebook and explore new ideas.
It is easy to get started, on your machine or the cloud.
# Advent of Code 2021
## Day 1
```elixir
"../aoc2021/day1.txt"
|> Path.expand(__DIR__)
|> File.read!()
|> String.split("\n", trim: true)
|> Enum.map(&String.to_integer/1)
|> Enum.chunk_every(2, 1, :discard)
|> Enum.filter(fn [a, b] -> a < b end)
|> length
```
## Day 4
```elixir
[numbers | boards] =
"../aoc2021/day1.txt"
|> Path.expand(__DIR__)
|> File.read!()
|> String.split("\n\n", trim: true)
# IO.inspect numbers
numbers |> String.split("\n", trim: true) |> Enum.map(&String.to_integer/1)
boards =
boards
|> Enum.map(fn b ->
b
|> String.split("\n", trim: true)
|> Enum.map(fn r -> r |> String.split(" ", trim: true) |> Enum.map(&String.to_integer/1) end)
end)
```
See source