The June 15, 2015 post on Bike Snob NYC leads with "Let's talk about bike locks." Here's what I want to talk about: in a local bike shop, I saw a combination lock called WordLock®, which replaces digits with letters. I classified this as a Fred lock, "Fred" being the term (championed by Bike Snob NYC) for an amateurish bicyclist with the wrong equipment. I tried the combination "FRED," and was amused with the result:

FRED BUNS! Naturally I bought the lock (and set the other ones on the rack to FRED BUNS as well). Unfortunately, it turns out the combination on each lock is pre-set; it can't be changed to FRED BUNS (some other models of WordLock® are user-settable). But we can still have fun writing code to answer some questions about the WordLock®:

How many words can the WordLock® make? Can a lock with different letters on the tumblers make more words? How many words can be made simultaneously? For example, with the tumbler set to "FRED", the lock above also makes "BUNS" in the next line, but with "SOMN", fails to make a word in the third line. Could different letters make words in every horizontal line? Is it a coincidence that the phrase "FRED BUNS" appears, or was it planted there by mischievous WordLock® designers?

Before we can answer the questions, we'll need to be clear about the vocabulary of the problem and how to represent concepts in code:

Lock : For our purposes a lock can be modeled as a list of 4 tumblers .

: For our purposes a lock can be modeled as a of 4 . Tumbler: Each tumbler has letters on it; in the lock above there are 4 tumblers, each with 10 distinct letters. I will represent a tumbler as a str of 10 letters.

Each tumbler has letters on it; in the lock above there are 4 tumblers, each with 10 distinct letters. I will represent a tumbler as a of 10 letters. Combination : Choosing a letter from each tumbler gives a combination, such as "FRED" or "BUNS". There are 4 10 = 10,000 combinations.

: Choosing a letter from each tumbler gives a combination, such as "FRED" or "BUNS". There are 4 = 10,000 combinations. Word: Some combinations (such as "BUNS") are words; others (such as "SOMN") are not words. We'll need a list of dictionary words.