Powered by AppSignal & Oban Pro
Would you like to see your link here? Contact us

Day01

lib/d01.livemd

Day01

args = File.read!("#{__DIR__}/../data/d1.txt")

Section

defmodule AoC do
  import Enum

  def parse(args) do
    args
    |> String.split("\n\n", trim: true)
    |> map(fn l -> map(String.split(l, "\n", trim: true), &String.to_integer/1) end)
    |> map(&sum(&1))
  end
end
args |> AoC.parse() |> Enum.max()
args |> AoC.parse() |> Enum.sort(:desc) |> Enum.take(3) |> Enum.sum()