17 lines
392 B
Elixir
17 lines
392 B
Elixir
defmodule ETL do
|
|
@doc """
|
|
Transforms an old Scrabble score system to a new one.
|
|
|
|
## Examples
|
|
|
|
iex> ETL.transform(%{1 => ["A", "E"], 2 => ["D", "G"]})
|
|
%{"a" => 1, "d" => 2, "e" => 1, "g" => 2}
|
|
"""
|
|
@spec transform(map) :: map
|
|
def transform(input) do
|
|
for {score, letters} <- input, letter <- letters, into: %{} do
|
|
{String.downcase(letter), score}
|
|
end
|
|
end
|
|
end
|