![word solver word solver](https://words-solver.com/wp-content/uploads/2020/09/words-solver-1080x1080-1.png)
![word solver word solver](https://playsposter.com/wp-content/uploads/2020/07/Word-Game-Solver-MOD-APK.png)
The fastest solution you're going to get will probably involve storing your dictionary in a trie. Doing the same in Python about doubles the speed. Print max(solve(), key=lambda (word, path): len(word))Įdit: Filter out words less than 3 letters long.Įdit 2: I was curious why Kent Fredric's Perl solution was faster it turns out to use regular-expression matching instead of a set of characters. Sample usage: # Print a maximal-length word and its path: Prefixes = set(word for word in wordsįor result in extending(letter, ((x, y),)):įor result in extending(prefix1, path + ((nx, ny),)):įor nx in range(max(0, x-1), min(x+2, ncols)):įor ny in range(max(0, y-1), min(y+2, nrows)): Words = set(word.rstrip('\n') for word in open('words') if bogglable(word)) (With a case-insensitive match.)īogglable = re.compile('$', re.I).match # A dictionary word that could be a solution must use only the grid's (I checked this against John Fouhy's solution.) After setup, the time to solve is down in the noise. My answer works like the others here, but I'll post it because it looks a bit faster than the other Python solutions, from setting up the dictionary faster. Paolo Bergantino, PHP (live link), ~5s (~2s locally).I am mostly looking for solutions using the Big 3 Ps: Python, PHP, and Perl, although anything with Java or C++ is cool too, since speed is essential. I am interested to see if any Stackoverflowers can come up with more efficient solutions. This takes a very long time to find the possible words, and since you only get 2 minutes per round, it is simply not adequate. My first attempt uses a dictionary such as this one (~2.3MB) and does a linear search trying to match combinations with dictionary entries. I am, unfortunately, not very good with algorithms or their efficiencies and so forth. While this game is fun and addictive, I am apparently not very good at it and I wanted to cheat a little bit by making a program that would give me the best possible words (the longer the word the more points you get). Words must be at least 3 characters, and no more than NxN characters, which would be 16 in this game but can vary in some implementations. So in the grid above, for example, I could come up with the words LOB, TUX, SEA, FAME, etc. You can start with any letter, and all the letters that surround it are fair game, and then once you move on to the next letter, all the letters that surround that letter are fair game, except for any previously used letters. The goal of the game is to find as many words as you can that can be formed by chaining letters together.
![word solver word solver](https://s.wordsolver.net/lib/images/2f.png)
Essentially, when the game starts you get a matrix of letters like so: F X I E Some of you may know this game as Boggle. Lately I have been playing a game on my iPhone called Scramble.