Hello Monks,

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:

C:\Users\tblaz\Documents\evelyn>perl 1.letters.pl letters are a g r t u i v b o ["a", "g", "r", "t", "u", "i", "v", "b", "o"] C:\Users\tblaz\Documents\evelyn>type 1.letters.pl #!/usr/bin/perl -w use 5.016; use Data::Dump; my @letters = qw(a g r t u i v b o); say "letters are @letters"; dd \@letters; __END__ C:\Users\tblaz\Documents\evelyn>

Greetings from the volcanic buttes of the Cascades, and thank you for your comment....


In reply to using perl to find words for scrabble by Aldebaran

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.