require 'letter_press_is_not_as_good_as_boggle' words = LetterPressIsNotAsGoodAsBoggle do board %w[n x g k o e e s i s v a j f e m l r g f z i a j b] guessed %w[averages vagaries lovemaking maligners remixing reimagines generalissimo fragile] end def score(word, targets) (targets - word.chars.to_a).size end preferred_chars = %w[g f] words.sort_by { |word| [-score(word, preferred_chars), word.size] } .each { |word| puts word }