- I'd like you to help me cheat at Scrabble. I'd like you to write some code to give me all possible words that can be created given a set of tiles. The maximum number of tiles you can have in Scrabble is seven, so you'll need to find all of the words that can be made out of those tiles.
On most unix systems (including Mac OS X), you can find a word dictionary in "/usr/share/dict/words" - let's assume that all of these words (including "zymogenic"!) are up valid for scrabble. Feel free to use your own custom dictionary, but this will do for this purpose.
Here's sample code that reads in all of the words into an array, removes newlines, and downcases them.
words = File.readlines("/usr/share/dict/words").map(&:chomp).map(&:downcase)
That only helps with the opening move of the game though. I need to be able to supply a letter to play off of that must be included in the words found.
While the length of the word is a useful proxy for it's Scrabble "goodness", it would really be helpful to find the highest scoring word(s) that I can play. Use the list of Scrabble tile values for the English language version of the game: https://en.wikipedia.org/wiki/Scrabble_letter_distributions#English