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
class AnagramTest < MiniTest::Unit::TestCase | |
class Anagram | |
def initialize(word) | |
@word = word | |
@anagram = Array.new | |
end | |
def match(candidates) |
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
class AnagramTest < MiniTest::Unit::TestCase | |
class Anagram | |
def initialize(word) | |
@word = word | |
# If you create the array here, then the results will be | |
# collected over multiple calls to `match`. Not sure if that is | |
# intended or not, so I'll assume it's ok to change. | |
end |
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
class AnagramTest < MiniTest::Unit::TestCase | |
class Anagram | |
def initialize(word) | |
@word = word | |
@anagram = Array.new | |
end | |
def match(candidates) | |
candidates.each do |candidate| |
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
def word_count | |
counts = Hash.new(0) | |
words.each do |word| | |
counts[word] += 1 | |
end | |
return counts | |
end |
NewerOlder