A friend suggested a fun little programming problem to me: efficiently matching scrabble tiles (including blanks or wildcards) to a dictionary of words.

he first thing I tried was a simple approach based on walking through a trie representation of the dictionary, and that did pretty well.

Another friend suggested that something using prime-based set membership testing might be fast. That’s what my eventual solution is based on, and the proof of concept is reasonably snappy.

Code: