
Jasmine
Administrator
/ Moderator
Feb 18, 2002, 8:57 PM
Views: 14905
|
|
Dictionary - 10 non-repeating letters from /usr/dict/words
|
|
|
Here's one of the examples provided at http://www.sysarch.com/perl/golf/. Try playing this yourself, then see other solutions at [url=http://www.sysarch.com/perl/golf/example.text]http://www.sysarch.com/perl/golf/example.text
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? Peter
(This post was edited by Jasmine on Feb 18, 2002, 9:03 PM)
|