Created
July 29, 2016 17:57
-
-
Save xikaos/c3af6d1a7dc319583ca1d516f729f0a0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Palindromes do | |
def run do | |
["amor", "roma", "phoenix", "mora", "elixir"] | |
|> Enum.group_by(&canonicalize/1) | |
|> IO.inspect | |
end | |
defp canonicalize(word) do | |
word | |
|> String.graphemes | |
|> Enum.sort | |
|> Enum.join | |
end | |
end | |
Palindromes.run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment