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

Day 1 - part2

day1-part2.livemd

Day 1 - part2

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

Part 2

input = Kino.Input.textarea("Please paste your input file:")
input
|> Kino.Input.read()
|> String.split("\n")
|> Enum.map(fn n ->
  unless n == "",
    do: String.to_integer(n)
end)
|> Enum.chunk_by(&is_integer/1)
|> Enum.filter(fn list -> list != [nil] end)
|> Enum.map(&Enum.sum/1)
|> dbg()
|> Enum.sort(:desc)
|> Enum.take(3)
|> Enum.sum()