Feeds:
Posts
Comments

Posts Tagged ‘keyboards’

A friend gave me this problem a couple of weeks ago:

What is the longest word you can type on the QWERTY keyboard with just your left hand using the proper position?

I love problems like this.

Especially because I get to toy around with Mathematica and use features that day to day I may not interact with for biz problems.

Finding the solution required only a tiny bit of code.

alpha = “”;
ourdictionary = “”;
alphabase = {“q” | “w” | “e” | “r” | “t” | “a” | “s” | “d” | “f” | “g” | “z” | “x” | “c” | “v” | “b”};
alpha = StringExpression[alpha, alphabase];

Code

n = 0;
dictionarycount = 0;
ourdictionary = DictionaryLookup[alpha];
While[n < 20 && Length@ourdictionary > 0,
ourdictionary = DictionaryLookup[alpha];
alpha = StringExpression[alpha, alphabase];
n++;
If[Length@ourdictionary == 0, Print[{Length@ourdictionary, n – 1}];
Print[DictionaryLookup[alpha[[;; n – 1]]]]]]

The Answer(s):

{“aftereffects”, “desegregated”, “desegregates”, “reverberated”, “reverberates”,”stewardesses”}

Read Full Post »