Created
April 10, 2020 04:15
-
-
Save kbseah/3bea8d13b55da90b779b3ca23bf80f77 to your computer and use it in GitHub Desktop.
Solver for the NY Times Spelling Bee game (https://www.nytimes.com/puzzles/spelling-bee), when you just need ONE MORE WORD ARGHGHG
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
dict = "/usr/share/dict/web2" # default path in Mac OS X | |
key = "H" # the letter that must be in the word | |
allowed = "CEKLMO" # other allowed letters | |
min = 4 | |
with open(dict, "r") as fh: | |
for word in fh: | |
word = word.rstrip().upper() | |
if key in word: | |
scores = 0 | |
for letter in word: | |
if letter not in key + allowed: | |
scores += 1 | |
if scores == 0 and len(word) >= min: | |
print(word) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment