|
|
|
|
|
by geor9e
679 days ago
|
|
time to LLM a binary search import requests
url = 'https://grandmasword.com/dictionary.js'
response = requests.get(url)
lines = response.text.split('\n')[2:]
exec('\n'.join(lines))
def binary_search(dictionary):
while len(dictionary) > 1:
mid_index = len(dictionary) // 2
mid_word = dictionary[mid_index]
print(f"Guess this middle word: {mid_word}")
user_input = input("Did grandma say her word is before or after? (type b or a)").strip().lower()
dictionary = dictionary[:mid_index] if user_input == "b" else dictionary[mid_index + 1:]
print(f"Grannys word: {dictionary[0]}" if dictionary else "No words left in the dictionary.")
binary_search(dictionary)
Solved in 18 guesses!
Share score
Thank you for visiting my website. There'll be a new word everyday just like Wordle. Kind regards, Eleanor |
|