exercism/elixir/etl/lib/etl.ex

17 lines
392 B
Elixir
Raw Normal View History

2024-06-27 03:30:11 +00:00
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