Created
August 31, 2011 17:22
-
-
Save altamic/1184114 to your computer and use it in GitHub Desktop.
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
words = Hash.new | |
File.open("dictionary.txt", "r") do |file| | |
while line = file.gets | |
word = line.chomp | |
words[word.split('').sort!.join('')] += [word] | |
end | |
end | |
loop do | |
print "Enter a word: " | |
anagram = gets.chomp | |
sorted_anagram = anagram.split('').sort!.join('') | |
p words[sorted_anagram] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment