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

Advent of Code 2015 Day 10 Part 1

2015_day10_part1.livemd

Advent of Code 2015 Day 10 Part 1

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

Get Inputs

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

My answer

Regex.scan(~r/(.)\1*/, puzzle_input)
get_char_group_list = fn input ->
  Regex.scan(~r/(.)\1*/, input)
  |> Enum.map(fn [max, min] ->
    "#{String.length(max)}#{min}"
  end)
  |> Enum.join()
end
get_char_group_list.("111221")
1..40
|> Enum.reduce(puzzle_input, fn _, acc_input ->
  get_char_group_list.(acc_input)
end)
|> String.length()