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

RE: [FWP] Puzzle thread on clpmod



> while ( /[a-e](?=[a-e]{4})/g ) {

Wouldn't

	while ( /([a-e]{5})/g ) {

have done the job, without an explicit look-ahead?

 - Andy Jacobs

-----Original Message-----
From: owner-fwp@technofile.org [mailto:owner-fwp@technofile.org]On
Behalf Of John Porter
Sent: Wednesday, July 07, 1999 8:43 AM
To: fwp@technofile.org
Subject: Re: [FWP] Puzzle thread on clpmod


RJK wrote:
> On Wed, Jul 07, 1999 at 10:51:20AM -0400, John Porter wrote:
> > RJK wrote:
> > > Counting variations, I have 26 words which fit (including those from
the
> > > original puzzle).
> 
> 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.

So, where did you find the 26?


> > while ( /[a-e](?=[a-e]{4})/g ) {
> 
> I especially like the use of look-ahead to match four characters.

Yep, this is one of those situations where it's really useful.


On reflection, I think I would rather have done this:

  while (<F>) {
    while ( /[a-e](?=[a-e]{4})/g ) {
      join( '', sort split //, substr $_, pos()-1, 5 ) eq 'abcde'
        and print and last;
    }
  }

It's actually noticeably faster.

John Porter


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

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