Mix.install([
{:kino, "~> 0.12.0"},
{:libgraph, "~> 0.16.0"}
])
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)