home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.questions
- Path: sparky!uunet!gatech!rpi!batcomputer!cornell!uw-beaver!news.tek.com!psgrain!m2xenix!agora!merlyn
- From: merlyn@ora.com (Randal L. Schwartz)
- Subject: Re: word cracker
- In-Reply-To: sscrivan@nyx.cs.du.edu's message of Wed, 30 Dec 92 23:51:26 GMT
- Message-ID: <MERLYN.93Jan2100550@agora.rain.com>
- Sender: merlyn@agora.rain.com (Randal L. Schwartz)
- Organization: Stonehenge Consulting Services; Portland, Oregon, USA
- References: <1992Dec30.235126.25601@mnemosyne.cs.du.edu>
- Date: Sat, 2 Jan 1993 18:05:50 GMT
- Lines: 45
-
- >>>>> In article <1992Dec30.235126.25601@mnemosyne.cs.du.edu>, sscrivan@nyx.cs.du.edu (steve scrivano) writes:
-
- steve> OK, gurus! Can anyone solve this problem?
-
- steve> I am looking for a fairly portable "C" program or script that will produce
- steve> every possible 4 letter or greater combination using the following
- steve> letters:
-
- steve> c e e f g h i i l l n n o p p r r r s s t t t u
-
- #!/usr/bin/perl
- open(W,"/usr/dict/words") || die "Get a Unix box, lunkhead!";
- while (<W>) {
- chop;
- next unless length >= 4; # skip short words
- $orig = $_; # for display
- tr/A-Z/a-z/;
- next if /[^cefghilnoprstu]/;
- # word contains only interesting characters
- $_ = pack("c*",sort unpack("c*",$_)); # sort to alpha order
- # ensure few enough characters of each type
- study; # may or may not help... try both
- next if /cc/;
- next if /eee/;
- next if /ff/;
- next if /gg/;
- next if /hh/;
- next if /iii/;
- next if /lll/;
- next if /nnn/;
- next if /oo/;
- next if /ppp/;
- next if /rrrr/;
- next if /sss/;
- next if /tttt/;
- next if /uu/;
- # good!
- print "$orig\n";
- }
-
- Just another Perl hacker,
- --
- Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
- merlyn@ora.com (semi-permanent) merlyn@agora.rain.com (for newsreading only)
- phrase: "Welcome to Portland, Oregon ... home of the California Raisins!"
-