Hacker News new | ask | show | jobs
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
4 comments

Classic 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.
Nevertheless, it is somewhat curious that "dictionary.js" is nearly valid python.
So 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
Going from knowing exactly what I want, to it materializing from just from a 60 second conversation in the sidebar of my browser, does give me a bit of a buzz
Fair enough! But I am curious, was it you or the LLM that decided to exec a .js file as python?
I 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
I mean that's literally how to play this game whether you intend to or not