You’ve got ~170k possible words and a pure higher/lower signal, so with perfect play it’s just binary search. Number the words 1 to 170k, guess the middle, then keep halving the range. In binary terms, each guess is basically telling you whether the next bit is 0 or 1.
Since log₂(170,000) ≈ 17.4, you need at most 18 guesses. On average it’s a bit less: about half the words take 18 guesses, a quarter take 17, an eighth take 16, etc. So the expected number of guesses works out to 17.
All of that assumes you know the exact ordering of the dictionary, of course. Once you don’t, it stops being optimal and starts being human. That’s where the difficulty actually comes from.
How are you getting the 170,000 number? I did a quick search and found this quote from merriam-webster.com [1]:
> Webster's Third New International Dictionary, Unabridged, together with its 1993 Addenda Section, includes some 470,000 entries. The Oxford English Dictionary, Second Edition, reports that it includes a similar number.
Im not going to lie, this one was more difficult than I thought. I did add this to The HN Arcade :) https://hnarcade.com/games/games/purple-word
Some interesting math here.
You’ve got ~170k possible words and a pure higher/lower signal, so with perfect play it’s just binary search. Number the words 1 to 170k, guess the middle, then keep halving the range. In binary terms, each guess is basically telling you whether the next bit is 0 or 1.
Since log₂(170,000) ≈ 17.4, you need at most 18 guesses. On average it’s a bit less: about half the words take 18 guesses, a quarter take 17, an eighth take 16, etc. So the expected number of guesses works out to 17.
All of that assumes you know the exact ordering of the dictionary, of course. Once you don’t, it stops being optimal and starts being human. That’s where the difficulty actually comes from.
How are you getting the 170,000 number? I did a quick search and found this quote from merriam-webster.com [1]:
> Webster's Third New International Dictionary, Unabridged, together with its 1993 Addenda Section, includes some 470,000 entries. The Oxford English Dictionary, Second Edition, reports that it includes a similar number.
[1] https://www.merriam-webster.com/help/faq-how-many-english-wo...
Interesting.
The word list / dictionary provided by the site only had around 170k lines so it must not be a complete version.
I would guess they have excluded some obscure words. I can't see anywhere in the information which dictionary is used.
Actually on a second look the wordlist has 279,498 words. I think it was only partially loaded when I first checked.
That bumps the math to log₂(279,498) ≈ 18.1, so 19 guesses in the worst case and about 18 on average with perfect play