Created
March 6, 2020 19:34
-
-
Save pikulet/fdc68f0dd093aa4e0b06178b5f861c3e to your computer and use it in GitHub Desktop.
Helper tool to help build your starters for Jotto :)
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
import string | |
import enchant | |
dictionary = enchant.Dict("en-US") | |
all_letters = string.ascii_lowercase; | |
def run(): | |
words = list() | |
current_letters = all_letters; | |
while True: | |
print(" ".join(current_letters)) | |
command = input("Enter a word, exit or reset\n") | |
if command == "exit": | |
break | |
if command == "reset": | |
print(words) | |
words = list() | |
current_letters = all_letters | |
continue | |
if len(set(command)) != 5: | |
print("Invalid jotto word") | |
continue | |
if not dictionary.check(command): | |
print("Invalid english word") | |
continue | |
length = len(current_letters) | |
next_letters = sorted(set(current_letters).difference(set(command))) | |
if length - len(next_letters) != 5: | |
print("Repeated letters used") | |
continue | |
else: | |
current_letters = next_letters | |
words.append(command) | |
if __name__ == "__main__": | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need python3,
pip3 install pyenchant
first.Example starters (thanks SteelixMega!!)