wordle/lib.py

26 lines
758 B
Python
Raw Normal View History

2022-01-18 21:52:14 +01:00
import string
2022-01-17 11:24:32 +01:00
DEBUG = False
WORD_LENGTH = 5
ROUNDS = 6
INSTRUCTIONS = "Positional letters (green) are CAPITAL, non-positional (yellow) are small, others are blanks e.g. SHe-r"
BLANK = "-"
2022-01-17 11:38:03 +01:00
DICTIONARY = '/usr/share/dict/words'
2022-01-17 11:24:32 +01:00
2022-01-17 11:38:03 +01:00
def cat_words(dictionary=DICTIONARY):
if type(dictionary) is list:
for word in dictionary:
yield word
else:
with open(dictionary) as f:
for word in f.readlines():
# remove end of line
word = word[:-1]
# filter out five letter words
2022-01-18 21:52:14 +01:00
if len(word) == WORD_LENGTH and all([letter in string.ascii_lowercase for letter in word]):
2022-01-17 11:38:03 +01:00
yield word
2022-01-18 21:52:14 +01:00
if __name__ == "__main__":
print(len(list(cat_words())))