home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / unix / question / 15116 < prev    next >
Encoding:
Text File  |  1993-01-02  |  1.8 KB  |  58 lines

  1. Newsgroups: comp.unix.questions
  2. Path: sparky!uunet!gatech!rpi!batcomputer!cornell!uw-beaver!news.tek.com!psgrain!m2xenix!agora!merlyn
  3. From: merlyn@ora.com (Randal L. Schwartz)
  4. Subject: Re: word cracker
  5. In-Reply-To: sscrivan@nyx.cs.du.edu's message of Wed, 30 Dec 92 23:51:26 GMT
  6. Message-ID: <MERLYN.93Jan2100550@agora.rain.com>
  7. Sender: merlyn@agora.rain.com (Randal L. Schwartz)
  8. Organization: Stonehenge Consulting Services; Portland, Oregon, USA
  9. References: <1992Dec30.235126.25601@mnemosyne.cs.du.edu>
  10. Date: Sat, 2 Jan 1993 18:05:50 GMT
  11. Lines: 45
  12.  
  13. >>>>> In article <1992Dec30.235126.25601@mnemosyne.cs.du.edu>, sscrivan@nyx.cs.du.edu (steve scrivano) writes:
  14.  
  15. steve> OK, gurus!  Can anyone solve this problem?
  16.  
  17. steve> I am looking for a fairly portable "C" program or script that will produce
  18. steve> every possible 4 letter or greater combination using the following
  19. steve> letters:
  20.  
  21. 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
  22.  
  23. #!/usr/bin/perl
  24. open(W,"/usr/dict/words") || die "Get a Unix box, lunkhead!";
  25. while (<W>) {
  26.     chop;
  27.     next unless length >= 4; # skip short words
  28.     $orig = $_; # for display
  29.     tr/A-Z/a-z/;
  30.     next if /[^cefghilnoprstu]/;
  31.     # word contains only interesting characters
  32.     $_ = pack("c*",sort unpack("c*",$_)); # sort to alpha order
  33.     # ensure few enough characters of each type
  34.     study; # may or may not help... try both
  35.     next if /cc/;
  36.     next if /eee/;
  37.     next if /ff/;
  38.     next if /gg/;
  39.     next if /hh/;
  40.     next if /iii/;
  41.     next if /lll/;
  42.     next if /nnn/;
  43.     next if /oo/;
  44.     next if /ppp/;
  45.     next if /rrrr/;
  46.     next if /sss/;
  47.     next if /tttt/;
  48.     next if /uu/;
  49.     # good!
  50.     print "$orig\n";
  51. }
  52.  
  53. Just another Perl hacker,
  54. -- 
  55. Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
  56. merlyn@ora.com (semi-permanent) merlyn@agora.rain.com (for newsreading only)
  57. phrase: "Welcome to Portland, Oregon ... home of the California Raisins!"
  58.