Skip to content

Instantly share code, notes, and snippets.

@alekst
Last active December 22, 2015 05:58
Show Gist options
  • Save alekst/6427318 to your computer and use it in GitHub Desktop.
Save alekst/6427318 to your computer and use it in GitHub Desktop.
class AnagramTest < MiniTest::Unit::TestCase
class Anagram
def initialize(word)
@word = word
@anagram = Array.new
end
def match(candidates)
candidates.each do |candidate|
if candidate.to_s.downcase.chars.sort.join == @word.to_s.downcase.chars.sort.join
@anagram << candidate unless candidate.downcase == @word
end
end
@anagram
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment