Skip to content

Instantly share code, notes, and snippets.

@avinson
Created August 26, 2015 00:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avinson/367d5993d992c2084e67 to your computer and use it in GitHub Desktop.
Save avinson/367d5993d992c2084e67 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
def anagram(word)
dict = ["cab", "bac", "pool", "loop", "polo"]
dict & word.chars.to_a.permutation.map(&:join)
end
puts anagram("oopl")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment