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

Untitled notebook

2021-lb/day_12.livemd

Untitled notebook

Section

Mix.install([
  {:kino, "~> 0.4.1"}
])
input = Kino.Input.textarea("Input")
edges =
  input
  |> Kino.Input.read()
  |> String.split("\n", trim: true)
  |> Enum.reduce(%{}, fn line, acc ->
    [left, right] = String.split(line, "-")
    acc = Map.update(acc, left, [right], &[right | &1])

    if left == "start" or right == "end" do
      acc
    else
      Map.update(acc, right, [left], &[left | &1])
    end
  end)