using perl to find words for scrabbleby Aldebaran (Chaplain)
|on Sep 04, 2019 at 23:06 UTC||Need Help??|
Aldebaran has asked for the wisdom of the Perl Monks concerning the following question:
I have been playing a variety of games like Scrabble and wanted to work up a perl utility to tilt the game in my favor. I've been mulling on how to capture the garden variety scrabble-like game. Clearly we need some sort of filesystem to house the lexicon of the language in question. I usually do things in other languages than english, but let's start there, as that is the current target environment. I think the gals I play with who are currently beating me would be amused at having been tagged to be within a "target environment." They've consented to let me use a perl script to help me on my phone during games, so I've downloaded Termux, and now I need to write the utility.
My basic question goes like this: Given an array of m @letters, which represents the single character tiles of the games, what english words can be formed for any subset n of m?
I think that if I tried to write my own, that I would be reinviting the wheel in significant ways, so let me throw it out there: are you aware of any existing solutions to this?
Left to my own devices, I would start enumerating cases in lexicographic order and then checking against a library whether the resulting "word" is legal. The list of words that count seems to crazy to me, with many short ones that don't get used in contemporary speech and then the absence of words I use all the time, like "perl." This is my humble start:
Greetings from the volcanic buttes of the Cascades, and thank you for your comment....