Solves the daily New York Times Spelling Bee challenge!
-
Words must include the center letter.
-
Words must contain at least four letters.
-
Letters can be used more than once.
-
Our word list does not include words that are offensive, obscure, hyphenated or proper nouns.
-
Four-letter words are worth one point each.
-
Longer words earn one point per letter. A six-letter word is worth six points.
-
Each puzzle includes at least one “pangram,” which uses every letter at least once. A pangram is worth an additional seven points."
On the website, input all of the optional letters, then all of the mandatory letters, and an output will come out!
Using a list of almost all of the words in the English language, the program creates 26 sets of words, each set representing all of the words that include one of the 26 letters anywhere in the word.
In order to find the final list, the program makes a union between all the sets of the optional letters, then intersects that with the set of the mandatory letter. Remember, union is to or as intersect is to and.
Another way to do it is by iterating through all of the combinations of the letters, but that is inefficient:
The
On the other hand, the
Here's my personal website: https://sites.google.com/view/daniel-chuang/home
Here's my GitHub: https://github.com/daniel-chuang