Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I ignored assumption #2, but the results of the following code do not violate that assumption (for this example anyway). I get two possible groups of five letters, for the sake of time, I'm not scanning any dictionary for these combinations. Even though it's probably easier to brute force a dictionary, I went the "let's find valid letter groups" route :)
use strict; use warnings; my $word = "aaaaa"; my @words; { push @words, $word if $word =~ tr/bumps// == 2 and $word =~ tr/seam// == 2 and $word =~ tr/domes// == 3 and $word =~ tr/shake// == 3 and $word =~ tr/pokes// == 3 and $word =~ tr/dukes// == 3; last if $word eq "zzzzz"; $word = inc_letter($word, 4); redo; } print "$_\n" for @words; sub inc_letter { my ($word, $i) = @_; if (substr($word, $i, 1) eq "z") { $word = inc_letter($word, $i-1, 1); substr($word, $i, 1) = substr($word, $i-1, 1); } else { substr($word, $i, 1)++; } $word; }
Update: The puzzle changed; this solution has not. If a general solution is desired, then more work would need to be done here.

In reply to Re: Challenge: Mystery Word Puzzle by runrig
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-29 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found