Skip to content

Instantly share code, notes, and snippets.

@krupenik
Created October 8, 2013 11:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krupenik/6883584 to your computer and use it in GitHub Desktop.
Save krupenik/6883584 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
letters = ARGV[0].split('')
words = open("/usr/share/dict/words").read.split(/\n/).reduce([]) do |words, word|
signature = word.chomp.downcase.split('')
words << word if signature == signature & letters
words
end
puts words.sort_by { |word| word.length }.inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment