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

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



>
>On Fri, Jul 16, 1999 at 12:24:05PM -0700, Vicki Brown wrote:
>> >From comp.lang.perl.mod:
>> 
>> This week's Weekend Edition Sunday Puzzle With Will Shortz on
>> National Public Radio presents a problem of a class that can be
>> defined as "match a substring of exactly n characters from the
>> unordered set of discrete characters { c1, c2, ..., cn }".

I think this was solved a few weeks back. Here is what I
remember. Don't remeber who's solution it was though.

my $words = '/usr/dict/words';
open (WORDS, "$words") || die "Cannot open file $words: $!";

while(<WORDS>) {
next unless length == 8 or length == 9;
print if (
			m/([a-e])(?!\1)
			([a-e])(?!\1|\2)
			([a-e])(?!\1|\2|\3)
			([a-e])(?!\1|\2|\3|\4)
			[a-e]/x
		);
}

-- 
Tim Allwine

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