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

day-1

advent_of_code_2022/day1.livemd

day-1

Mix.install([
  {:kino, "~> 0.7.0"}
])

Section

input = Kino.Input.textarea("Input")
# the elf with the most has
input
|> Kino.Input.read()
|> String.split("\n\n")
|> Enum.map(&String.split(&1, "\n"))
|> Enum.map(fn chunk -> Enum.map(chunk, &String.to_integer/1) end)
|> Enum.map(&Enum.sum/1)
# calories
|> Enum.max()
# the three elves with the most have
input
|> Kino.Input.read()
|> String.split("\n\n")
|> Enum.map(&String.split(&1, "\n"))
|> Enum.map(fn chunk -> Enum.map(chunk, &String.to_integer/1) end)
|> Enum.map(&Enum.sum/1)
|> Enum.sort()
|> Enum.take(-3)
# calories total
|> Enum.sum()