Earlier quoted context omitted.
let l = 0; let h = dictionary.length - 1; const textbox = document.querySelector("input"); while (l 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.
Thanks! I should have realised that a solution for this could be implemented in JavaScript as well, allowing it to run directly in the web browser. Here is my translation of my earlier Python program to JavaScript: let lo = 0, hi = dictionary.length - 1 const answer = document.getElementById('guess') while (document.getElementsByClassName('correct').length === 0) { const mid = Math.floor(lo + (hi - lo) / 2) answer.va…
Show HN: My 70 year old grandma is learning to code and made a word game
141–150 of 160 posts
Re: Show HN: My 70 year old grandma is learning to code and made a word game
#142Suggestions, limit to 5 chars and use a Wordle-like interface so your phone can’t suggest words.
I could see this being a legit NYT game.
Re: Show HN: My 70 year old grandma is learning to code and made a word game
#143This is a fun game and it's harder than it looks! I'm impressed! She should produce a random word from the dictionary instead of hard coding it, and keep it going!
Then you can't compete with friends and family, sending links, spreading the game...
Re: Show HN: My 70 year old grandma is learning to code and made a word game
#144Re: Show HN: My 70 year old grandma is learning to code and made a word game
#145Re: Show HN: My 70 year old grandma is learning to code and made a word game
#146Re: Show HN: My 70 year old grandma is learning to code and made a word game
#147 secretWords = ['test', 'test', 'test', 'horse', 'chocolate', 'garden', 'volcano', 'orange', 'elephant', 'star', 'violin', 'egg', 'pencil', 'forest', 'lamp', 'island', 'potato', 'happy', 'toilet', 'shell'];Re: Show HN: My 70 year old grandma is learning to code and made a word game
#148Re: Show HN: My 70 year old grandma is learning to code and made a word game
#149Now trolling here
https://www.reddit.com/r/programming/comments/1enuhw5/commen...
Re: Show HN: My 70 year old grandma is learning to code and made a word game
#150Reading the code is a joy. I love seeing different approaches to what we all take as givens, such as design.css rather than style.css, or the usage of an `else if (1 == 1)` compared to `else` or even `else if (true)`. (So I guess, thanks for not teaching her about bundlers and minifiers yet :))
One reason programmers do this is so that they can make a one character change, e.g. "else if (1 === 1)" -> "else if (1 === 2)" in order to change the logic there. For C programers you see a lot of '#if 0' '#if 1' for this same purpose. Though, given that it's used everywhere, I'm not sure if it's really for that purpose.