[pm-h] Thanks Again For Joining Me for "Solving WordBrain"

Todd Rinaldo todd at rinaldo.us
Mon Mar 14 07:52:19 PDT 2016


Robert,

I spent way to much time thinking about this problem yesterday.

I came up with this REALLY cool recursive algorithm to find all the
possible 8 letter combinations given 16 characters. and then piped it into
aspell -a since Text::Aspell is too slow. It turns out aspell  -a is too
slow too also. I think it's because it's spending all its time trying to
give you alternate spellings when you really just want it to tell you yes
or no.

Watching the output I realized the code was spending WAY too much time
determining if a series of combinations was right when the human watching
the output scroll by could obviously see that nothing starts with "sse". So
I went and found a 350,000 word text dictionary and wrote something that
could answer: anything_starts_with("sse"); It turns out you can save even
more time if you know what the word length will need to be since what you
really want to know is "does any word of length 8 start with sse?"

So the joke is that I now had my program running time on this program from
5+ minutes to 30 seconds:

$> time perl -Ilib -MWordBrain::Combos
-E'WordBrain::Combos::find_words("ssehrckeionisswl", [4, 4, 8]);'

At this point I was still using aspell when I had the final word to verify
it. It occurred to me I could use my anything_starts_with check on the 8
character string just as good as the partials. I made this change and
suddenly the program time dropped to 3 seconds.

So TL;DR; Aspell sucks for what this code needs it for. Code attached to
make run time reasonable. What I'd probably do is NOT use find_words but
instead just use anything_starts_with() to short my maze walker when I get
to an invalid sequence. I suspect that would bring almost all puzzles down
to a manageable time. NOTE You have to clear the cache and set
$max_dict_word_len when your word length changes.

I could not divine how to go about altering the code to make this work.

Code attached.




On Wed, Feb 17, 2016 at 7:48 PM, Robert Stone via Houston <houston at pm.org
<javascript:;>> wrote:
> Greetings,
>
> A tremendous THANK YOU to everyone who was able to join me for my "Solving
> WordBrain" presentation.  It certainly is a little rough around the edges
> but I really appreciate the opportunity to present to everyone.
>
> Moreover, the feedback provided was fantastic!  I'm looking forward to
> implementing some of the changes everyone suggested.
>
> I hope everyone enjoyed the presentation as much as I enjoyed delivering
it.
> Thank you all again for having me.
>
> Best Regards,
> Robert Stone
>
> _______________________________________________
> Houston mailing list
> Houston at pm.org <javascript:;>
> http://mail.pm.org/mailman/listinfo/houston
> Website: http://houston.pm.org/



--
Todd Rinaldo
todd at rinaldo.us <javascript:;>


-- 
Todd Rinaldo
todd at rinaldo.us
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/houston/attachments/20160314/2f1ea2d8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Combos.pm
Type: text/x-perl-script
Size: 2422 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/houston/attachments/20160314/2f1ea2d8/attachment.bin>


More information about the Houston mailing list