Skip to content

Instantly share code, notes, and snippets.

@kbseah
Created April 10, 2020 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kbseah/3bea8d13b55da90b779b3ca23bf80f77 to your computer and use it in GitHub Desktop.
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
#!/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