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

Advent of Code 2015 Day 2 Part 2

2015_day2_part2.livemd

Advent of Code 2015 Day 2 Part 2

Mix.install([
  {:kino_aoc, "~> 0.1"}
])

Get Inputs

{:ok, puzzle_input} =
  KinoAOC.download_puzzle("2015", "2", System.fetch_env!("LB_SESSION"))

My answer

puzzle_input
|> String.split("\n")
|> Enum.map(fn row ->
  [l, w, h] =
    row
    |> String.split("x")
    |> Enum.map(&String.to_integer(&1))

  min_length = Enum.min([l + w, w + h, h + l])

  2 * min_length + l * w * h
end)
|> Enum.sum()