Why does your 'bad' run not show the %master_letter_freq hash like the 'good' run does? Can there be some problem in the calculation of that hash? Does the 'w' from the pattern get counted somehow? Is the 'w' from the pattern already on the board? If so, with a 'w' on your 'rack', words should be allowed to have two 'w's.

As a side note, my favorite way of answering the question "What words can be made with these letters?" is to match against a regex. Here's an example:

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11132707 use warnings; my $letters = 'otrwreh'; my $have = '...w'; # NOTE: using . instead of - my $pattern = join '', map "$_?", sort split //, $letters; my $regex = qr/^$pattern$/im; print "regex: $regex\n\n"; @ARGV = '/usr/share/dict/words'; /^$have$/i && (join '', sort /./g) =~ $regex && print while <>;

which outputs the computed regex and the matching words:

regex: (?^mi:^e?h?o?r?r?t?w?$) thew trow

this allows for only as many of a letter as initially specified.


In reply to Re: Next from inner loop only works "most of the time" by tybalt89
in thread Next from inner loop only works "most of the time" by Marshall

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.