All posts by phobic

Wordbrain Solver – 6×6 – With filtering v.3

I have shortened down some of the code, added clearing of screen before printout and added support for 6×6 puzzles. I have not got this far yet, so I have no idea on the runtime. But I’ll guess it is exponential from 5×5. This means I need to add the check of two first and last letters, maybe also another one for the three first and last letters. I wanted to add some more sexiness to the printout, so I made an old school percentage bar. When I start the program in Terminal, it looks like this.

The new code is here:



Wordbrain solver – letter permutations

When you are stuck after partly solving a puzzle, there is a chance that the puzzle is solved in the wrong order. Using my path seeking algorithm might not work, since the letter are in the wrong place in the matrix. The remaining letters are however correct. This is why I made a simple program for finding all possible permutations of the remaining letter, disregarding the location. The program also compares against the Norwegian dictionary. You type in the letters and choose length of the word.

The program uses a library for permutations:

Norwegian dictionary as Python dict format: wordDict.txt

Terminal output:

Wordbrain Solver – 5×5 – Brute-Force with filtering v.2

Second attempt for this. The previous 5×5 code was estimated to use 12.5 days to get all possible words. Going through the code, I found some weak spots:

  • No control of word length. The program was traversing through words of lengths up to 25. This means extremely long paths with extremely many different variations. Reduced this to maximum traversing 9 letter words.
  • Checking all possible paths, even some that was unnecessary. I made a new dictionary containing all existing first-and-last letters  in a Norwegian dictionary. This way, instead of checking all possible paths between example ‘z’ to ‘ø’, I can skip all these paths immediately, as no words starts and ends with these letters. This would skip 1/600th of the total time.

This reduced the solution time from 22500 minutes to around 7 minutes (!!!). The 4×4 puzzles was also reduced from 10 minutes to 40 seconds.

Implementations for next version:

  • Create a wordlist for all two-first and two-last characters existing from Norwegian dictionary words. This will skip even more unnecessary paths for finding words.
  • Add a filter for the words lengths necessary, the puzzles will show example three-letter, five-letter and nine-letter word.
  • Move all found words to separate dicts and make a function that deletes all words containing one letter, in cases when a word found contains the last letter of one type. This is a quick way to “thin out” the possible words.