Skip to content

Instantly share code, notes, and snippets.

@jedrekk
Created October 11, 2020 16:25
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 jedrekk/7ff3717f5522e6125e5ffe566a15ebed to your computer and use it in GitHub Desktop.
Save jedrekk/7ff3717f5522e6125e5ffe566a15ebed to your computer and use it in GitHub Desktop.
Find all words matching the NY Times Spelling Bee letters
# words4.txt is a wordlist of 4 letter or longer words
# usage: spelling_bee_nyt.py A BCDEFG
# where A is the required letter
#!/usr/bin/python3
import sys
magic_letter = sys.argv[1]
other_letters = sys.argv[2]
words_with_magic = 0
def fullword(letters, word):
return "".join(set(letters.lower())) == "".join(set(word.lower()))
def checkword(letters, word):
for l in word.lower():
if l not in letters.lower():
return False
return True
with open('words4.txt', 'r') as lines:
for liner in lines:
good = True
line = liner.strip()
if magic_letter.lower() not in line:
continue
if fullword(other_letters + magic_letter, line):
print("XXX", line)
elif checkword(other_letters + magic_letter, line):
print(line)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment