Here’s some silly Python 2.x code to display a list of words that can be typed solely with one hand. Of course any word can be typed one handed if you’re a hunt and peck typist…
The list might be useful for passwords or for people who need to um… er… type one handed. Um like someone writing a lipogram…
The code can be sped up on Python 2.4 by changing the list comprehensions “[ x for x in y]” to generator expressions “(x for x in y)”. Generator comprehensions are more efficient: processing 234,937 words on my 1.5GHz Powerbook takes 23.768 seconds with list comprensions and 11.157 seconds with generator comprehensions.
The longest words found in this dictionary were:
AFTERCATARACT
PHYLLOPHYLLIN
TESSERADECADE
Next time you use one of those in scrabble don’t forget to remind your opponent that the word can be typed one-handed.
#!/usr/local/bin/python
theLeft = 'QWERTASDFGZXCV'
theRight = 'YUIOPHJKLBNM'
theFile = file('/usr/share/dict/words')
### Remove line endings...
theWords = [theLine.rstrip('\r\n') for theLine in theFile.readlines()]
### Remove single letters...
theWords = [theWord for theWord in theWords if len(theWord) > 1]
### Make the words upper case...
theWords = [theWord.upper() for theWord in theWords]
### Check to find words made up of only left hand letters or right hand letters but not both...
theWords = [theWord for theWord in theWords if not (True in [X in theLeft for X in theWord]) == (True in [X in theRight for X in theWord])]
### Print out the words...
for theWord in theWords:
print theWord