defmodule AoC.Util.Enum do @doc """ Transposes (in the sense of matrices) a collection of nested enums. iex> AoC.Util.Enum.transpose( iex> [[1,2,3], [4,5,6], [7,8,9]] iex> ) [[1,4,7],[2,5,8],[3,6,9]] """ def transpose(enum) do col_count = enum |> Enum.at(0) |> Enum.count() for col <- 0..(col_count - 1) do enum |> Enum.map(&Enum.at(&1, col)) end end end