Updated: to comply with all the revised rules.

Here's cleaner version of the above that also deals with (all?) of the edge cases.

#! perl -slw use strict; sub uniq { my %x; @x{@_} = (); keys %x } my $len = shift @ARGV; my $re ; my $re_ex; my $cap = 1; my $cap_ex = 1; my $hints_uniq; for my $i ( 0 .. $#ARGV ) { my( $word, $common ) = split ':', $ARGV[ $i ]; my $uniq = join'', uniq( split '', $word ); $hints_uniq .= $uniq; if( $common <= length $word ) { $re_ex .= "\n\t(?= (?: .*? (?: [^$uniq] | (?: ([$uniq])(?= + .* \\" . $cap_ex++ . ") ) ) ){" . ( $len - $common ) . "} )" } if( $common >= 2 ) { $re .= "\n\t(?=.*?([$word]).*?(?!\\$cap)"; if( $common > 2 ) { my $base = $cap; for my $n ( 1 .. $common-2 ) { $re .= "([$word]).*?(?!" . join('|', map{ '\\' . $_ } $base .. ++$cap ) . ")"; } } $cap++; $re .= "[$word])"; } elsif( $common == 1 ) { $re .= "\n\t(?=.*[$word].*)" } } $hints_uniq = join '', uniq split'', $hints_uniq; my $re_covered = qr[^[$hints_uniq]+$]; $re = qr[^$re]x; $re_ex = qr[$re_ex]x; my %w; open W, '<', 'words' or die $!; m[^[a-z]+$] and push @{ $w{ length() } }, $_ while chomp( $_ = <W>||'' ); close W; my @m = grep{ $_ =~ $re_covered and $_ =~ $re_ex and $_ =~ $re } @{ $ +w{ $len } }; print ~~@m; print for @m;

Examine what is said, not who speaks.
Silence betokens consent.
Love the truth but pardon error.

In reply to Re^2: Challenge: Mystery Word Puzzle by BrowserUk
in thread Challenge: Mystery Word Puzzle by Limbic~Region

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.