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

Advent of Code 2023 Day 12

2023/12.livemd

Advent of Code 2023 Day 12

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

Section

input = Kino.Input.textarea("input")
defmodule HotSprings do
  def parse_sections(row) do
    {
      String.split(hd(row), "", trim: true),
      String.split(Enum.at(tl(row), 0), ",", trim: true)
    }
  end

  def parse_row(row) do
    row
    |> String.split(" ", trim: true)
    |> parse_sections
  end

  def parse(input) do
    Kino.Input.read(input)
    |> String.split("\n", trim: true)
    |> Enum.map(&parse_row/1)
  end
end
HotSprings.parse(input)