Comment

Comment by yismail

let l = 0; let h = dictionary.length - 1;

const textbox = document.querySelector("input");

while (l <= h) { const m = Math.floor((l + h) / 2); const guess = dictionary[m]; const textbox = document.querySelector("input"); console.log("Guessing:", guess);

  textbox.value = guess;
  guessWord();

  if (document.querySelector(".correct")) {
    console.log("Found the word:", guess);
    break;
  } else if (textbox.placeholder.includes("after")) {
    l = m + 1;
  } else {
    h = m - 1;
  }
}

Here's mine in JavaScript, you can paste it in the console.

parent yismail 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton