Skip to content

Instantly share code, notes, and snippets.

@cameronabrams
Created October 18, 2021 20:17
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 cameronabrams/58b64f389f677941b45c8d75b90f3779 to your computer and use it in GitHub Desktop.
Save cameronabrams/58b64f389f677941b45c8d75b90f3779 to your computer and use it in GitHub Desktop.
Don't cheat at the New York Times Spelling Bee!
''' Cheat at NYT Spelling Bee '''
import random
class Words:
def __init__(self):
with open('/usr/share/dict/words','r') as f:
raw=f.read().split('\n')
self.words=[w.upper() for w in raw if (not "'" in w and len(w)>3 and w.islower())]
self.sevens=[w for w in self.words if (len(w)==7 and len(set(w))==7)]
def findbees(self,letters):
if len(set(letters))!=7:
print('Bad letter set:',letters)
return []
res=[]
for w in self.words:
if letters[0] in w:
good=True
for l in w:
if l not in letters:
good=False
if good:
res.append(w+('*' if len(set(w))==7 else ''))
return res
if __name__=='__main__':
U=Words()
for bee in U.findbees('CHEATOR'):
print(bee)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment