"if we look at that word uh we see it's nines so i'm going to put that into my code and…
- User
"if we look at that word uh we see it's nines so i'm going to put that into my code and run it in verbose mode so we can see exactly how it operates correct word nines and let's make sure that's in verbose so what do we see in our in our pattern here is that whatever letters we could correct in the first guess we always keep in the subsequent guesses so the second guess we see that um we have an i an s and an e in it because every single word in our dictionary has been filtered to match this result i mean that that seems to work pretty well until you get to this case where um every single word remaining in the dictionary looks like i n e s there's nines dimes binds all these words and we just don't get enough information with each subsequent guess because we're limiting ourselves to using the same letters so we have five letters to play with and we're only getting more information from the very first letter so i've already been kind of tinkering around and i've got an optimization here which it's going to work like this we're going to keep track of two lists of words one is going to be the answer space which contains the potential remaining word after it's been filtered out each guess there's going to be a second word list which is every single word in the dictionary that never gets filtered and what we're going to do is build our letter frequencies so which words should we should we favor and try to pick that'll be our answer space which continues to get filtered but the guess we're going to do is going to be from all words so we're going to pick a word that can get us more of these letters at a single time and not even worry about letters we've already picked it's just gonna the whole goal is to filter the answer space down to a single word and then finally it'll guess it so there we go we start with the same word and given those clues we filter the word list down so we still only have 248 words remaining in the dictionary but we pick a totally different word that doesn't even contain any of the same letters so we're actually getting way more information on the second guess we go from 248 words down to 15. if we look at this one we went from 248 down to 77 so we didn't filter as much because we just didn't get as much information so it's still not perfect but we get get in eight guesses instead of thirteen so let me clear out uh we'll go back to 100 games and not verbose and we're not going to force it to be nines anymore and let's see the overall average performance all right so we have improvement took an average of five guesses 5.1 guesses so that's better than previously was over 5.3 and our worst case is only eight so we're super close to being able to solve this 100 of the time but we have a couple seven and eight guesses which would push us over the limit for the game so let's actually try this i'm going to turn my game into play mode and we'll try it on today's puzzle so let me i'm going to load today's puzzle and let's fire up the game so the first guess it wants me to do is acer and we see uh x x x y y next guess con tg and the game tells us that that word is not in the list so that's not even a valid guess according to the game so we have a huge problem here our dictionary of guesses and possible answers does not match the game's dictionary and possible answers so what i'm gonna have to do is figure out what words this game accepts make sure that our code uses the same exact list so we've done some digging in to the games code and we can see that it actually has the entire list of words uh right here and there's something interesting which is that they have two lists one is a list of words you can type in and it'll accept that as a guess the other is a list of words that it will use as potential answers and so if you want to go through this you can see where it where it picks a word for the answer in this function here so we know that um that first list is possible answers and this is the list that you'll it'll use for anything that can be typed in and accept it so i went ahead and downloaded those lists i copied those in to my own text file and so i have two lists now one is possible words these are actual answers that could be in the game and then there's accepted words so these are words that you could type in and it'll allow that and we already kind of have this in our code um we just did it in a different form because we started with the same word list so instead of loading one list we're going to load both lists and i have my answer list which is the possible words and i'm never going to filter this or i'm going to filter this list as i go but the accepted words i'm never going to filter we're always going to search through this list to pick our next best guess so let me go ahead and load this in all right here we are just by filtering that list down to the dictionary they provided we are at a magic 3.88 and only six gas worst case which means our program should be able to crack this 100 of the time got one last optimization plugged into the pick word function " Add pronunciations to the above paragraph.
- Assistant