Skip to content

Instantly share code, notes, and snippets.

Created Jul 27, 2013
What would you like to do?
Anagram koan
defmodule Anagram do
@doc """
# Anagram
Given a word and a list of possible anagrams, selects the correct one(s).
## Example
iex> Anagram.match "listen",%w(enlists google inlets banana)
def match(word,words) do
normalized_word = normalize_word(word)
Enum.filter words, fn x -> normalized_word==normalize_word(x) end
defp normalize_word(word) do
word |> String.codepoints |> Enum.sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment