Skip to content

Instantly share code, notes, and snippets.

@michaelnugent
Last active December 15, 2015 18:59
Show Gist options
  • Select an option

  • Save michaelnugent/5307736 to your computer and use it in GitHub Desktop.

Select an option

Save michaelnugent/5307736 to your computer and use it in GitHub Desktop.
Anagram problem
#!/usr/bin/env ruby
File.open("/usr/share/dict/words") do |handle|
cachedsorted = ARGV[0].chars.sort
handle.each_line do |word|
puts word if word.strip.chars.sort == cachedsorted
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment