15 lines
321 B
Elixir
15 lines
321 B
Elixir
|
defmodule Anagram do
|
||
|
@spec anagram?(a :: String.t(), b :: String.t()) :: boolean
|
||
|
def anagram?(a, b) do
|
||
|
Map.equal?(to_symbols(a), to_symbols(b))
|
||
|
end
|
||
|
|
||
|
@spec to_symbols(a :: String.t()) :: map()
|
||
|
defp to_symbols(a) do
|
||
|
a
|
||
|
|> String.downcase()
|
||
|
|> String.graphemes()
|
||
|
|> Enum.frequencies()
|
||
|
end
|
||
|
end
|