Friday 18 September 2015

Typewriter

Words that can be typed by using exactly one set of keys, i.e.
Either
Q W E R T Y U I O P
or
A S D F G H J K L
or
Z X C V B N M

import re

if __name__ == '__main__':
    regex = re.compile(r'^([qwertyuiop]*|[asdfghjkl]*|[zxcvbnm]*)$')
    with open('words.txt', 'r') as fptr:
        for word in fptr:
            if regex.match(word):
                meat = regex.match(word).group(1)
                # Print words with length greater than 7:
                if len(meat) > 7:
                    print('%s (%d)' % (meat, len(meat)))
etiquette (9)
perpetuity (10)
pirouette (9)
potpourri (9)
preterite (9)
prettier (8)
priority (8)
property (8)
proprietor (10)
propriety (9)
prototype (9)
puppeteer (9)
puppetry (8)
repertoire (10)
repertory (9)
reporter (8)
territory (9)
torturer (8)
tripwire (8)
typewriter (10)

Typewriter is one of the largest in the result set, but not the only one.