Postby kcameron » Thu Dec 12, 2013 1:42 am UTC
Being the obsessive sort, I had to test the results myself. Here's my perl script:
#!/usr/bin/env perl
use strict;
my %words;
while (<>) {
chomp; s/\015//g; # get rid of line terminators (including dos formatted files)
$_ = lc; # force lower case
next if /[^a-z]/; # skip words with non-alpha characters (e.g. hyphens)
next if !$_; # skip blank lines
next if $words{$_}; # ignore dups
# map word into raw key info
my $pcnt = $_;
my $kseq = $_;
$kseq =~ tr/a-z/22233344455566677778889999/; # key pressed for each letter
$pcnt =~ tr/a-z/12312312312312312341231234/; # key press count for each letter
# abcdefghijklmnopqrstuvwxyz
# create wait counts
my @rep_raw;
@rep_raw = $kseq =~ m/(.)(\1+)/g; # order pairs of first key press followed by repeats
my $odd = 1;
my @rep = grep $odd = !$odd, @rep_raw; # list of repeats
my $totw = length (join "", @rep); # total waits for word
my @waits = sort (map length, @rep);
my $maxw = $waits[$#waits] || "0"; # maximum waits before moving to new key
# total key presses
my $kcnt=0;
map $kcnt+=$_, (split //, $pcnt);
# produce qwerty keyboard stats
my $is_homerow = m/^[asdfghjkl]+$/;
my $is_lefthand = m/^[qwertasdfgzxcvb]+$/;
my $is_righthand = m/^[yuiophjklnm]+$/;
# save info about the word
$words{$_} = {
'kseq' => $kseq,
'pcnt' => $pcnt,
'wlen' => length,
'kcnt' => $kcnt,
'maxw' => $maxw,
'totw' => $totw,
'file' => $ARGV,
'is_homerow' => $is_homerow,
'is_lefthand' => $is_lefthand,
'is_righthand'=> $is_righthand,
'all' => 1,
};
#printf "$_,keys:$kseq,cnts:$pcnt,len:%d,kcnt:$kcnt,maxw:$maxw,totw:$totw,rep:@rep,is_homerow:$is_homerow,is_lefthand:$is_lefthand,is_righthand:$is_righthand\n", length;
}
my $wkey;
sub by_wkey {
$words{$b}->{$wkey} <=> $words{$a}->{$wkey} || # note reverse numeric sort built-in
$a cmp $b # break tie with word alpha sort
;
}
sub proc_wkey {
my ($msg, $wcond);
($wkey, $wcond, $msg) = @_;
# extract the set of words matching the max for the key
my @ord_words = grep $words{$_}->{$wcond}, sort by_wkey keys %words;
my @max_words = (shift @ord_words);
my $max_val = $words{$max_words[0]}->{$wkey};
while (my $word = shift @ord_words) {
my $val = $words{$word}->{$wkey};
last if $val < $max_val;
push @max_words, $word;
}
push @max_words, @ord_words[0..4]; # add a few close words for fun
# Output info for all the words which equal the max value
printf "$msg:\n";
foreach my $word (@max_words) {
printf " %-50s: length:%2d, total key presses:%3d, key waits on one key: %3d, total key waits:%3d, file:%s\n", $word, $words{$word}->{wlen}, $words{$word}->{kcnt}, $words{$word}->{maxw}, $words{$word}->{totw}, $words{$word}->{file};
}
}
printf "%d unique words were examined\n", scalar (keys %words);
proc_wkey ("wlen", "all", "Words with most letters");
proc_wkey ("kcnt", "all", "Words with max total key presses");
proc_wkey ("maxw", "all", "Words with max one key wait");
proc_wkey ("totw", "all", "Words with largest total wait");
proc_wkey ("wlen", "is_homerow", "Longest words on QWERTY home row");
proc_wkey ("wlen", "is_lefthand", "Longest words on QWERTY left hand");
proc_wkey ("wlen", "is_righthand", "Longest words on QWERTY right hand");
0;
Here's the results:
localhost:~/try/keypad%./countkeys.pl wordsEn.txt corncob_lowercase.txt /usr/share/dict/words
418034 unique words were examined
Words with most letters:
pneumonoultramicroscopicsilicovolcanoconiosis : length:45, total key presses:118, key waits on one key: 3, total key waits: 6, file:/usr/share/dict/words
cyclotrimethylenetrinitramine : length:29, total key presses: 65, key waits on one key: 0, total key waits: 0, file:/usr/share/dict/words
trinitrophenylmethylnitramine : length:29, total key presses: 62, key waits on one key: 0, total key waits: 0, file:/usr/share/dict/words
antidisestablishmentarianism : length:28, total key presses: 61, key waits on one key: 1, total key waits: 1, file:wordsEn.txt
hydroxydehydrocorticosterone : length:28, total key presses: 68, key waits on one key: 1, total key waits: 3, file:/usr/share/dict/words
electroencephalographically : length:27, total key presses: 60, key waits on one key: 1, total key waits: 3, file:/usr/share/dict/words
Words with max total key presses:
pneumonoultramicroscopicsilicovolcanoconiosis : length:45, total key presses:118, key waits on one key: 3, total key waits: 6, file:/usr/share/dict/words
hydroxydehydrocorticosterone : length:28, total key presses: 68, key waits on one key: 1, total key waits: 3, file:/usr/share/dict/words
hydroxydesoxycorticosterone : length:27, total key presses: 68, key waits on one key: 1, total key waits: 4, file:/usr/share/dict/words
cyclotrimethylenetrinitramine : length:29, total key presses: 65, key waits on one key: 0, total key waits: 0, file:/usr/share/dict/words
philosophicopsychological : length:25, total key presses: 64, key waits on one key: 1, total key waits: 5, file:/usr/share/dict/words
microspectrophotometrically : length:27, total key presses: 63, key waits on one key: 1, total key waits: 4, file:/usr/share/dict/words
Words with max one key wait:
deedeed : length: 7, total key presses: 11, key waits on one key: 6, total key waits: 6, file:/usr/share/dict/words
fiddledeedee : length:12, total key presses: 23, key waits on one key: 6, total key waits: 7, file:/usr/share/dict/words
homonomous : length:10, total key presses: 24, key waits on one key: 6, total key waits: 6, file:/usr/share/dict/words
mononomial : length:10, total key presses: 22, key waits on one key: 6, total key waits: 6, file:/usr/share/dict/words
mononomian : length:10, total key presses: 21, key waits on one key: 6, total key waits: 6, file:/usr/share/dict/words
nonmonogamous : length:13, total key presses: 28, key waits on one key: 6, total key waits: 7, file:/usr/share/dict/words
nonmonogamously : length:15, total key presses: 34, key waits on one key: 6, total key waits: 7, file:/usr/share/dict/words
nonmonopolistic : length:15, total key presses: 37, key waits on one key: 6, total key waits: 6, file:/usr/share/dict/words
nonmonotheistic : length:15, total key presses: 35, key waits on one key: 6, total key waits: 6, file:/usr/share/dict/words
asarabacca : length:10, total key presses: 20, key waits on one key: 5, total key waits: 5, file:/usr/share/dict/words
bacaba : length: 6, total key presses: 10, key waits on one key: 5, total key waits: 5, file:/usr/share/dict/words
baccaceous : length:10, total key presses: 24, key waits on one key: 5, total key waits: 5, file:/usr/share/dict/words
caccabis : length: 8, total key presses: 20, key waits on one key: 5, total key waits: 5, file:/usr/share/dict/words
chrononomy : length:10, total key presses: 25, key waits on one key: 5, total key waits: 5, file:/usr/share/dict/words
Words with largest total wait:
gnomonologically : length:16, total key presses: 38, key waits on one key: 5, total key waits: 8, file:/usr/share/dict/words
nonaccommodable : length:15, total key presses: 31, key waits on one key: 3, total key waits: 8, file:/usr/share/dict/words
nonaccommodably : length:15, total key presses: 32, key waits on one key: 3, total key waits: 8, file:/usr/share/dict/words
nonaccommodatingness : length:20, total key presses: 43, key waits on one key: 3, total key waits: 8, file:/usr/share/dict/words
nonautonomousness : length:17, total key presses: 41, key waits on one key: 4, total key waits: 8, file:/usr/share/dict/words
nonmonarchically : length:16, total key presses: 38, key waits on one key: 5, total key waits: 8, file:/usr/share/dict/words
nontrigonometrically : length:20, total key presses: 46, key waits on one key: 3, total key waits: 8, file:/usr/share/dict/words
pseudomonocotyledonous : length:22, total key presses: 52, key waits on one key: 4, total key waits: 8, file:/usr/share/dict/words
ammonocarbonous : length:15, total key presses: 34, key waits on one key: 4, total key waits: 7, file:/usr/share/dict/words
automorphically : length:15, total key presses: 33, key waits on one key: 2, total key waits: 7, file:/usr/share/dict/words
cabbageheadedness : length:17, total key presses: 33, key waits on one key: 4, total key waits: 7, file:/usr/share/dict/words
cacodemonomania : length:15, total key presses: 30, key waits on one key: 4, total key waits: 7, file:/usr/share/dict/words
cannonballed : length:12, total key presses: 25, key waits on one key: 3, total key waits: 7, file:wordsEn.txt
Longest words on QWERTY home row:
haggadahs : length: 9, total key presses: 14, key waits on one key: 1, total key waits: 1, file:/usr/share/dict/words
falashas : length: 8, total key presses: 19, key waits on one key: 0, total key waits: 0, file:/usr/share/dict/words
flagfall : length: 8, total key presses: 18, key waits on one key: 1, total key waits: 1, file:/usr/share/dict/words
galagala : length: 8, total key presses: 12, key waits on one key: 0, total key waits: 0, file:/usr/share/dict/words
galahads : length: 8, total key presses: 14, key waits on one key: 0, total key waits: 0, file:wordsEn.txt
hadassah : length: 8, total key presses: 16, key waits on one key: 1, total key waits: 1, file:/usr/share/dict/words
Longest words on QWERTY left hand:
redrawerredrawers : length:17, total key presses: 36, key waits on one key: 1, total key waits: 4, file:/usr/share/dict/words
devertebrated : length:13, total key presses: 24, key waits on one key: 1, total key waits: 2, file:/usr/share/dict/words
tesseradecade : length:13, total key presses: 27, key waits on one key: 1, total key waits: 4, file:/usr/share/dict/words
aftereffects : length:12, total key presses: 28, key waits on one key: 3, total key waits: 3, file:wordsEn.txt
decerebrated : length:12, total key presses: 23, key waits on one key: 1, total key waits: 2, file:/usr/share/dict/words
desegregated : length:12, total key presses: 21, key waits on one key: 1, total key waits: 2, file:wordsEn.txt
Longest words on QWERTY right hand:
phyllophyllin : length:13, total key presses: 32, key waits on one key: 1, total key waits: 2, file:/usr/share/dict/words
miminypiminy : length:12, total key presses: 26, key waits on one key: 0, total key waits: 0, file:/usr/share/dict/words
hypolimnion : length:11, total key presses: 26, key waits on one key: 1, total key waits: 2, file:/usr/share/dict/words
hypophyllum : length:11, total key presses: 24, key waits on one key: 1, total key waits: 1, file:/usr/share/dict/words
kinnikinnik : length:11, total key presses: 26, key waits on one key: 1, total key waits: 2, file:/usr/share/dict/words
polyphonium : length:11, total key presses: 24, key waits on one key: 1, total key waits: 1, file:/usr/share/dict/words
I believe Randall got it wrong. It seems that the question was asking which English word is most annoying to type on a cell keypad based on the total number of times one must pause prior to starting a new letter. From my wordlists, the answer is "gnomonologically" which requires 8 pauses. "nonmonogamous" has only 7 pauses. Note that the longest word "pneumonoultramicroscopicsilicovolcanoconiosis" requires 118 key presses but only 6 pauses.
Last edited by
kcameron on Thu Dec 12, 2013 5:37 pm UTC, edited 2 times in total.