[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] Puzzle thread on clpmod



On Wed, Jul 07, 1999 at 10:51:20AM -0400, John Porter wrote:
> 
> RJK wrote:
> > On Tue, Jul 06, 1999 at 04:26:37PM -0700, tushar@i-works.com wrote:
> > > 
> > > Could someone figure out what they are?
> > 
> > Counting variations, I have 26 words which fit (including those from the
> > original puzzle).
> 
> Wow.  My system's dictionary file (Solaris 2.6 /usr/share/lib/dict/words)
> contains only two, a 7-letter and an 8-letter.

On the other hand, I have been humbled by the list of words Ken Pizzini
posted for 'abcde': he found 18 words which contain 'abcde' consecutively.
My word list only has 8.


/usr/dict/words is not a good word list to search for words, for two
reasons, both relating to its use by `spell`.

First, it contains ordinal numbers, proper names, computer terms, etc.

Second, for regular conjugations and declensions, it only contains the
root.  You will find 'walk', but not 'walks', 'walked', or 'walking'.


> Here's my perl solution:
> 
>   open F, "< /usr/share/lib/dict/words" or die "open words file: $!\n";
>   while (<F>) {
>     chomp;
>     while ( /[a-e](?=[a-e]{4})/g ) {
>       join( '', sort split //, substr( $_, pos()-1, 5 ) ) eq 'abcde' or next;
>       print "$_\n";
>       last;
>     }
>   }
>   close F;
> 

This looks like it works similarly to my solution.  Your code is cleaner
than mine though.  I especially like the use of look-ahead to match four
characters.

Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe