# # 1. Read word list # word list is long (over 200,000 words!) so we # just print the first 100; this goes away later # 2. Eliminate words that are not exactly 5 characters long # 3. Read pattern, characters that must be in the word ("good # letters"), characters that are not in the word ("bad # letters") # print them to verify they are right, and then quit; # this goes away later # # Matt Bishop, MHI 289I, Fall 2025 # import sys # # the word list # wordlist = "/usr/share/dict/words" # # get pattern, good, bad letters # try: pat = input("Pattern: ") good = input("Letters you know are in the word: ") bad = input("Letters you know are not in the word: ") except Exception as msg: print(msg) sys.exit(1) # # print them # print(f"Pattern: '{pat}'") print(f"Good: '{good}'") print(f"Bad: '{bad}'") # # don't need to print the word list # to test this # sys.exit(0) # # open the word list # try: wl = open(wordlist, "r") except Exception as msg: print(msg) sys.exit(1) count = 0 # # print possible words # for word in wl: # remove trailing (and leading!) space word = word.strip() # skip words not exactly 5 characters long if len(word) != 5: continue print(word) # stop after 100 words printed count += 1 if count > 100: break