Created
October 11, 2020 16:25
-
-
Save jedrekk/7ff3717f5522e6125e5ffe566a15ebed to your computer and use it in GitHub Desktop.
Find all words matching the NY Times Spelling Bee letters
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
# 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