Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Anagram Solver
## Name data from
## Originally used on 8 Aug to find an anagram of a name. Neural.
FILENAME = "/Users/ckinniburgh/Dropbox/Development/AnagramSolver/yob1991.txt"
puts "Input anagram: "
anagram = gets.chomp
puts "Finding an anagram for " + anagram + "."
anagramArray = anagram.downcase.scan(/./).sort!
f = or die "Where's your file? I sure can't find and open it."
f.each_line { |line|
testName = line.split(/,/)[0].downcase.scan(/./).sort!
if testName == anagramArray
puts line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.