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

Day 17: Clumsy Crucible

day17.livemd

Day 17: Clumsy Crucible

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

Input

input = Kino.Input.textarea("Please, paste your input here:")
defmodule Day17Shared do
  def parse(input) do
    input
    |> Kino.Input.read()
    |> String.split("\n")
    |> Enum.with_index()
    |> Enum.reduce(%{}, fn {row, y}, map ->
      row
      |> String.split("", trim: true)
      |> Enum.with_index()
      |> Enum.reduce(map, fn {amount, x}, map ->
        Map.put(map, {x, y}, String.to_integer(amount))
      end)
    end)
  end
end

Day17Shared.parse(input)