DEV Community

Discussion on: Help me solve the "Triple Trouble" challenge on Codewars with Elixir.

Collapse
 
antonrich profile image
Anton • Edited

Spoiler:
Guys on reddit helped me with the problem.

My final solution is this:

defmodule Triple do
  def triple_trouble(one, two, three) do
    list = [one, two, three]
    [first, second, third] = Enum.map(list, &String.graphemes/1)

    Enum.zip([first, second, third])
    |> Enum.map(&Tuple.to_list/1)
    |> List.flatten
    |> Enum.join
  end
end
Collapse
 
chenge profile image
chenge • Edited

You can add a "elixir" after 3 symbols to get color. Your solution is quite good for read.

defmodule Triple do
  def triple_trouble(one, two, three) do
    list = [one, two, three]
    [first, second, third] = Enum.map(list, &String.graphemes/1)

    Enum.zip([first, second, third])
    |> Enum.map(&Tuple.to_list/1)
    |> List.flatten
    |> Enum.join
  end
end
Collapse
 
antonrich profile image
Anton

Thanks, I added the colors.