DEV Community

Discussion on: Daily Challenge #202 - Complete the Pattern II

Collapse
 
savagepixie profile image
SavagePixie

Elixir

I based my solution on the examples, rather than the explanation.

  def pattern(n) when n < 1, do: " "
  def pattern(n) do
    list = for x <- 1..n, do: n..x
      |> Enum.to_list
      |> Integer.undigits
      |> Integer.to_string
    Enum.join(list, "\n")
  end