Someone mentioned recently that "typewriter
was the longest word that can be typed on the top row of a qwerty keyboard".
I thought that was interesting. I was curious to know what other words were in the running. So I thought would write some
code to find out.
First, I need a list of all the words in the English language. I didn't have to look very far. Every Linux and Mac system
has a list available. On my 2023 16-inch Macbook Pro, it lives at /usr/share/dict/words
. My mac is set to US English.
Second, I need to filter that list so that it only has words made up of the letters qwertyuiop
. To get this, you just
need a little regular expression magic. I always start looking at grep for this. I try what I expect work. When it doesn't,
I re-learn for the ump-teenth time, that grep
on Mac doesn't support PCRE (Perl Compatible Regular Expressions). No matter
how you feel about Perl, their regular expression engine is the one that every other programming language emulates.
It turns out that Mac has a program called pcre2grep
, which does exactly what I want.
pcre2grep '^[qwertyuiop]+$' /usr/share/dict/words > qwertyuiop.txt
I wrote a CLI script using PHP. It's designed to read STDIN. Here's how you run the script.
cat qwertyuiop.txt | php sort_by_word_length.php
It turns out that typewriter
is pretty long at 10 letters. Here are "all" the 10-letter words. I use quotes here,
becuase it's possible that the dictionary used to make my /usr/share/dict/words
is missing some words from other
regions and locales.
pepperroot
pepperwort
perpetuity
pewterwort
pirouetter
prerequire
pretorture
proprietor
repertoire
repetitory
tetterwort
typewriter
There are however, 3 words with 11 letters. So we have a 3-way tie!
proprietory
proterotype
rupturewort
If you're thinking - I've never even heard of these words - you're not alone. So here's what proprietory , proterotype, and rupturewort mean.