There are some fairly dubious coding practices in there, and I don't yet guarentee it solves every puzzle, but it does solve the (now removed) example.

I'll try test it a bit more and clean it up a bit.

#! perl -slw use strict; sub uniq { my %x; @x{@_} = (); keys %x } my $len = shift @ARGV; my $re = '^'; my $c = 0; for my $i ( 0 .. $#ARGV ) { my( $word, $common ) = split ':', $ARGV[ $i ]; die "Bad arg '$ARGV[ $i ]'" unless $common >= 2 and $common <= length( $word ); my $uniq = join'', uniq( split '', $word ); $re .= "(?=(?:.*?[^$uniq]){${ \ ($len - $common) }})"; $c++; $re .= "(?=.*?([$word]).*?(?!\\$c)"; $re .= "([$word]).*?(?!" . join( '|', map{ "\\${ \ $c++ }" } 0 .. $common-2 ) . ')' and --$c if $common > 2; $re .= "[$word])"; } $re .= '.' x $len . '$'; $re = qr[$re]; my %w; open W, '<', 'words' or die $!; m[^[a-z]+$] and push @{ $w{ length() } }, $_ while chomp( $_ = <W>||'' + ); close W; my @m = grep{ $_ =~ $re } @{ $w{ $len } }; print ~~@m; print for @m; __END__ P:\test>421692-1 5 bumps:2 seams:2 domes:3 shake:3 pokes:3 dukes:3 1 house

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

In reply to Re: 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.