tracks/elixir/exercises/saddle-points/example.exs in trackler-2.2.1.109 vs tracks/elixir/exercises/saddle-points/example.exs in trackler-2.2.1.110

- old
+ new

@@ -22,11 +22,11 @@ """ @spec columns(String.t()) :: [[integer]] def columns(str) do str |> rows - |> List.zip + |> List.zip() |> Enum.map(&Tuple.to_list/1) end @doc """ Calculates all the saddle points from a string @@ -34,10 +34,11 @@ """ @spec saddle_points(String.t()) :: [{integer, integer}] def saddle_points(str) do rows = rows(str) columns = columns(str) + rows |> generate_coordinates |> Enum.filter(&is_saddle_point?(&1, rows, columns)) end @@ -55,15 +56,15 @@ Enum.at(column, x) == Enum.min(column) end defp generate_coordinates(rows) do rows - |> Enum.with_index + |> Enum.with_index() |> Enum.flat_map(&generate_coordinates_row/1) end defp generate_coordinates_row({row, row_index}) do row - |> Enum.with_index + |> Enum.with_index() |> Enum.map(fn {_, col_index} -> {row_index, col_index} end) end end