diff --git a/lib/algox/walk_on_matrix.ex b/lib/algox/walk_on_matrix.ex index a1c0117..ce7be81 100644 --- a/lib/algox/walk_on_matrix.ex +++ b/lib/algox/walk_on_matrix.ex @@ -31,7 +31,7 @@ defmodule WalkOnMatrix do defp sort([head | tail], unsorted_rows, sorted_row) when tail === [] do [last_elem | rest] = segregate_last_elem(head, []) sorted_row = [last_elem | sorted_row] - sorted_row = add_to_sorted(rest, sorted_row) + sorted_row = reverse_row(rest, sorted_row) sort(unsorted_rows, [], sorted_row) end @@ -44,12 +44,6 @@ defmodule WalkOnMatrix do sort(tail, unsorted_rows, sorted_row) end - defp add_to_sorted([], sorted), do: sorted - - defp add_to_sorted([head | tail], sorted) do - add_to_sorted(tail, [head | sorted]) - end - defp reverse_row([], reversed_row), do: reversed_row defp reverse_row([head | tail], reversed_row) do