I ultimately want to duplicate the results from this online tool, which produces perfect results ... The hidden message is supposed to be LYNNBUETTNERART, but my version produces LYNNBUETTNRART... (note the missing second E), whereas the the online tool gets this right.

Have you solved the puzzle by hand; are you sure the online tool is getting it "right"? One of your words is "EEL", which happens to appear on the second line, 12th character, down. That's where that "E" between "TN" and "RART" on the third line is probably going. Perhaps your ruleset is different from what the online tool is using. I'm guessing the online tool only matches each word once, and if that's the case, how does it determine which match has priority? Anyway, my suggestion:

  1. Decide on the set of rules used for solving. (Without these specs, it's difficult to give advice on a solution anyway!)
  2. Write many test cases, solving them by hand.
  3. Work on your algorithm until all tests pass.

Step 2 can get a little annoying, but Step 3 usually makes up for that, that feeling when all your tests pass is great :-)

Here's a template:

#!/usr/bin/env perl use warnings; use strict; use Test::More; is solve("FOO\nBAR\nOOF\n", ['FOO']), 'BAR'; my $INPUT1 = <<'_X_'; BFOO AQUZ ROOF _X_ my @WORDS1 = qw/ FOO BAR /; is solve($INPUT1, \@WORDS1), 'QUZ'; # more test cases here! done_testing; sub solve { my ($grid, $words) = @_; my $solution = "..."; # your algorithm here! return $solution; }

In reply to Re: Improving this word search solver by Anonymous Monk
in thread Improving this word search solver by phizel

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.