7
1
The New York Times periodically runs a puzzle they call the "Spelling Bee" in which they list six "allowed" letters plus one "mandatory" letter and challenge the reader to form as many five-letter-or-longer dictionary words as possible out of those letters. Each "allowed" letter can appear 0 or more times. The mandatory letter must appear at least once in each word. No other letters are allowed. Proper nouns are not acceptable answers.
For example, in last week's puzzle, the allowed letters were {"A", "C", "D", "H", "I", and "R"}
, while the mandatory letter was "N"
.
Allowed answers for this set of letters range from 5-letter words "ranch", "naiad", and "nadir", up to 9-letter words "cnidarian" and "circadian".
The more words you find, the higher the Times rates your intelligence. Your challenge: write a solver in the language of your choice.
Additional rules and tips:
If your programming environment or operating system provides a list of words, you may use it. If not, you must include code for loading a word list from disk or the internet; you can not assume it has been magically loaded into a variable outside your code.
The word list should be generic, not limited to only those words that contain the mandatory letter, and not limited to words that meet the length or other requirements here. In other words, all dictionary searches should be done by your code, not some pre-processor.
If a word is capitalized in the dictionary, treat it as a proper noun. If your dictionary does not distinguish proper nouns, find a different dictionary.
Different dictionaries will deliver different sets of answers, but given the test case above, you must return at least 20 qualifying answers, and the words "harridan", "niacin", and "circadian" must be on it. The words "Diana", "Adrian", and "India", as proper nouns, must not be.
Your code should take the form of a function or program that accepts two variables: a string or list of characters representing the allowed letters, and a character representing the required letter. It should return a list of allowed answers in any order.
Except to the extent my rules here dictate otherwise, standard loopholes are forbidden.
In the event my rule summary here deviates from the rules at the New York Times, follow the rules here.
Shortest byte count wins, though I plan to call out excellent solutions using novel algorithms or that are otherwise interesting to me, assuming any such are submitted.
2
I might recommend just specifying the appropriate wordlist and its file name, a la "Let's Play Hangman".
– briantist – 2017-02-26T00:33:04.120Also the standard here is to allow a program or function, why is this limited to a function specifically?
– briantist – 2017-02-26T00:35:10.7674"you can not assume it has been magically loaded into a variable outside your code" - how about just accepting a list of words as an input to the (program or) function? – Jonathan Allan – 2017-02-26T00:58:02.770
The word
india
is also the code word for the letter I in international radio communication, and hence not a proper noun, so could be listed in the dictionary as such (CSW has it for example and that has no proper nouns). – Jonathan Allan – 2017-02-26T03:06:03.960@briantist I suppose a program that follows the other rules would be fine. I will modify the terms accordingly. – Michael Stern – 2017-02-26T04:17:07.290