Re:The 'Spelling Bee Honeycomb' puzzle: efficient computatio...
by matrixlab on Friday January 17, 2020 @09:46AM
(#22074987)
Very nice! I also took a bitwise approach and ended up with something that solved all possible puzzles in 5 seconds (in 60 lines of matlab).
A technique I used that helped bring the time down was to calculate the points for a given puzzle irregardless of the center letter. This provides an upper bound for the points that could come from that puzzle. After you've done that for all the boards, you sort by upper bound and then start calculating the actual scores for the different center letter options. Doing this for the 538 puzzle, I only had to look at center letters for the top 2 puzzles 'aeginrt' and 'adeinrt' (after those you find a score that is greater than the upper bound for any of the other puzzles).
Re:The 'Spelling Bee Honeycomb' puzzle: efficient computatio...
by JoeAltmaier on Friday January 17, 2020 @09:53AM
(#22075040)
Its amazing the speedups if you have the right model for the problem!
Re:The 'Spelling Bee Honeycomb' puzzle: efficient computatio...
by jim-jim-jim on Friday January 17, 2020 @04:54AM
(#22073347)
Very cool. I also wrote a solver using the NYT magazine's rules back in 2018, and found the bitwise method of matching both 1 and 3 point values incredibly fast. I just precalculated the hashes and ran a parallel loop over the whole array, but I know there are specialized data structures that games like Scrabble use. I wonder if that would have sped things up even more.
Anyway, whenever I see a problem that involves letters now, I reach for bit operators first.
I used the “hard copy” rule set as used in the printed New York Times, which is slightly different from the web rule set: words must be at least five letters long, not four, and are worth 1 point each, or 3 for a pangram. The hard copy puzzles also include three score thresholds, so I had a bit of fun trying to reverse-engineer how those thresholds are chosen. I didn’t get exactly the right function, but I got fairly close, and most importantly the thresholds feel fair when playing. (The online version also has score thresholds, but there are many more of them, and it was easy for me to transcribe thresholds from the archives of the printed copies.)
In my admittedly biased yet assuredly humble opinion, both the algorithm performance and the rating threshold estimation are interesting: https://github.com/wchargin/spelling-bee/tree/master#perform...
Oh, and a web-based solver, for convenience: https://wchargin.github.io/spelling-bee/
Lovely to see how the author of this article and I both had a lot of fun with this by taking it in different directions. :-)