This challenge comes from listener Gerry Reynolds of Chicago. Name a national landmark (6,3). Add the name of a chemical element. Rearrange all the letters to name two states. What are they?
Immediately we can see this is essentially the familiar puzzle format: f_x(string1) = string2. That is, we're looking for string1 and string2, where each is a word or phrase; we're given function x, and when we apply function x to string1 the result is string2.
Two things are a little different this time, however. First, each string we're matching is actually a pair of strings---no big deal. Second, we're dealing with two closed classes and one open class. These are common concepts in language and linguistics. A closed class is a fixed list that doesn't change, like determiners (roughly articles) or prepositions. We could come up with a complete list of all English prepositions, and it really doesn't change much from year to year or even decade to decade. An open class is list that expands, like verbs and nouns. We could try but we'd never really come up with a complete list of these, and new words enter the language every year. Of course, we can list all 50 states easily, and we can list all 118 elements easily---not from memory, but that's okay!
So we have states and landmarks covered, but we need a list of landmarks. As I often do, I suggest we start with Wikipedia and see if there are any pages from which we can easily extract a list.
Assuming we have all three lists, how do we begin? Here's my plan:
- keep only landmarks that fit (6,3) (i.e., a 6-letter word followed by a 3-letter word)
- generate all landmark-element pairs
- generate all state-state pairs
- for each landmark-element pair, compare each state-state pair for a match:
- for comparison, for each pair: lowercase, remove non-letters, sort letters, join all letters to single sorted string; e.g., ["North Dakota", "Ohio"] --> "aadhhiknoooortt"
No comments:
Post a Comment