Elixir Adjacent Elements Product
defmodule AdjacentElementsProduct do
def adjacent_elements_product(input_array) do
input_array
|> Enum.chunk_every(2, 1, :discard)
|> Enum.map(fn [a, b] -> a * b end)
|> Enum.max()
end
end
This walks through neighboring values, multiplies each pair, and keeps the biggest product it finds.