-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Sorry for mis-using the issues section here to share my results, but I couldn't resist 😄
My solution finds all 538 sets in around 50 seconds (with multi-threading on an 8-core CPU).
I'm not using fancy math (I know that's nothing to be proud of) but a few other tricks, which appear to speed things up a little:
-
Valid five-word sets must use 25 out of 26 characters. Therefore, I select words containing two rare letters
(xand / orq, there are only 315 such words) and use only them as 'seed words'. Then I only have to find four
more words per seed word. Because every valid set must contain either anxand / or aqI can't miss a set. -
Initially, I build 26 sets (one for each letter) containing all words that include the particular letter. This
helps in efficiently removing invalid word candidates later on. -
The search function works recursively and removes invalid words from the list of candidates for deeper recursion
levels (using the words-by-letter sets mentioned above). This way the search can terminate early once there are no more word candidates left.
The code is pretty simple (~150 lines including comments), however I used kotlin as programming language instead of python.