Created
September 4, 2013 12:42
-
-
Save alekst/6436407 to your computer and use it in GitHub Desktop.
This file contains 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
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.turning_into_letters == @word.turning_into_letters | |
@anagram << candidate unless candidate.downcase == @word | |
end | |
end | |
@anagram | |
end | |
def turning_into_letters(word) | |
word.to_s.downcase.chars.sort | |
end | |
private :turning_into_letters | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment