Elixir
Elixir with recursion:
def dezerofy(0), do: 0 def dezerofy(n), do: _dezerofy(n, rem(n, 10)) defp _dezerofy(n, 0), do: _dezerofy(div(n, 10), rem(n, 100)) defp _dezerofy(n, _), do: n
Elixir without recursion, inspired by @avalander 's solution:
def dezerofy(0), do: 0 def dezerofy(n), do: n |> Integer.digits |> Enum.reverse |> Enum.drop_while(&(&1 == 0)) |> Enum.reverse |> Integer.undigits
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Elixir
Elixir with recursion:
Elixir without recursion, inspired by @avalander 's solution: