Advent of Code 2023 Day 1 Part 1
Mix.install([
{:kino_aoc, "~> 0.1"}
])
Get Inputs
{:ok, puzzle_input} =
KinoAOC.download_puzzle("2023", "1", System.fetch_env!("LB_SESSION"))
My answer
puzzle_input
|> String.split("\n")
|> Enum.map(fn line ->
digits = Regex.scan(~r/[0-9]/, line)
first = digits |> hd() |> hd()
last = digits |> Enum.reverse() |> hd() |> hd()
String.to_integer(first <> last)
end)
|> Enum.sum()