10 letter words with no duplicate letters

egrep '^[a-z].{9}$' /usr/share/dict/words \
| awk '{ 
    ok = 1; 
    for ( i=1; i<=length($0); i++) { 
        c = substr( $0, i, 1 );  
        if ( counts[ c ] ) { 
            ok = 0; 
            break; 
        }
        counts[ c ] = 1;
     } 
  if ( ok ) print $0;
  delete counts; 
}'
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: