3 ms·
time to LLM a binary search import requests url = 'https://grandmasword.com/dictionary.js' response = requests.get(url) lines = response.text.split('\n
by geor9e 2y 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
- tills13 2y agoI mean that's literally how to play this game whether you intend to or not
- another-dave 2y agoI thought my manual binary search off the top of my head in 16 guesses was probably poor but if it beats a coded version, I'm happier now lol
- robertclaus 2y agoClassic LLM hijinks or hacker goofing off on HN? Either might throw `exec('\n'.join(lines))` in a script running on a publicly downloaded file rather than parsing it more directly.
- jessekv 2y agoNevertheless, it is somewhat curious that "dictionary.js" is nearly valid python.
- jessekv 2y agoSo you didn't want to have fun playing the game, but also didn't want to have fun coding a solver? I understand the former, but not the latter... :D