Can ChatGPT help with writing more idiomatic Elixir?

Hello,
You really should take into account that each call to Enum in the final code implies a full walk through the entire list. So this can be ok for small lists but I for myself consider this as bad style.
The Enum module is full of functions that really should be studied in-depth as to find the appropriate one for the desired behavior.
In your case, I would use reduce that does all in one pass: traverse the list, do the proper conversion you need as in your first function and calc the sum in the accumulator, all in one pass.

So I would write it like this:

def part_1(input) do
    input
    |> String.split("\n\n")
    |> Enum.map(fn s ->
      s
      |> String.split("\n")
      |> Enum.reduce(0, fn t, acc ->
        t |> String.trim() |> String.to_integer() |> Kernel.+(acc)
      end)
    end)
    |> Enum.max()
  end

Cheers,
Sébastien.

3 Likes