Problem 3 in Elixir