CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Fun With Perl: Perl Golf: Dictionary - 10 non-repeating letters from /usr/dict/words: Edit Log

Administrator / Moderator

Feb 18, 2002, 8:57 PM

Views: 49645
Dictionary - 10 non-repeating letters from /usr/dict/words

Here's one of the examples provided at Try playing this yourself, then see other solutions at [url=]

In Reply To
From: Peter Marksteiner <hump@concealed>
Subject: Golf problem
Date: 28 Jun 2000 09:34:14 GMT

Suppose you want to find words with exactly ten non-repeating letters such
as "binoculars", "fishmonger", or "paintbrush", suitable for games or simple
encryption of numbers where every decimal digit is represented by a letter.

I've tried to write the shortest possible Perl program to extract
such words from a wordlist and have found the following two solutions:

perl -pe '%c=();length==11&!grep{$c{$_}++}split""or$_=""' /usr/dict/words
perl -pe '$_=""if(keys%{{map{$_,1}split""}})*length!=121' /usr/dict/words

Is there anybody who can do it with fewer keystrokes?


(This post was edited by Jasmine on Feb 18, 2002, 9:03 PM)

Edit Log:
Post edited by Jasmine (Administrator) on Feb 18, 2002, 9:03 PM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives