in reply to Improving this word search solver
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:
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; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Improving this word search solver
by phizel (Acolyte) on Jan 21, 2015 at 01:41 UTC | |
by Anonymous Monk on Jan 21, 2015 at 02:03 UTC | |
by phizel (Acolyte) on Jan 21, 2015 at 02:13 UTC | |
by Laurent_R (Canon) on Jan 21, 2015 at 07:24 UTC |