Day 9
Mix.install([
{:kino, "~> 0.11.0"}
])
Section
input = Kino.Input.textarea("input")
defmodule OASIS do
def extrapolate([0]), do: 0
def extrapolate(numbers) do
hd(numbers) +
(numbers
|> Enum.chunk_every(2, 1, :discard)
|> Enum.map(&apply(Kernel, :-, &1))
|> extrapolate())
end
end
input
|> Kino.Input.read()
|> String.split("\n")
|> Enum.map(fn line ->
line
|> String.split(" ", trim: true)
|> Enum.map(&String.to_integer/1)
|> Enum.reverse()
|> OASIS.extrapolate()
end)
|> Enum.sum()
input
|> Kino.Input.read()
|> String.split("\n")
|> Enum.map(fn line ->
line
|> String.split(" ", trim: true)
|> Enum.map(&String.to_integer/1)
# |> Enum.reverse()
|> OASIS.extrapolate()
end)
|> Enum.sum()