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

Re: [FWP] Weekend Edition Sunday Puzzle (from c.l.p.mod)



> I heard a similiar problem which supposedly had just one solution.
> A word with abcde in order but not necessarily contiguous:
>
> /a.*b.*c.*d.*e/
>
> I would like to verify the solution, but alas, no dict on the system.


No; based upon the below code. But I only have a 220K words file.

#!/usr/local/bin/perl -wT

use strict;
use diagnostics -verbose;

my $len = -1;

open WORDS, "words" or die "No words file: $!";

while (<WORDS>) {
 chomp;              # no newline...
            s/#.*//; # no comments...
           s/^\s+//; # no leading whitespace...
           s/\s+$//; # no trailing whitespace...
 next unless length; # anything to process?

 while (++$len <= length) {
      print "\nInside of $_, I found ", substr($_, $len, 1)
          if (index(/a.*b.*c.*d.*e/, $_) > -1);
  }

$len = -1;
}

INTL,
-Sneex-  :]

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