Hacker News new | ask | show | jobs
by rlpb 5890 days ago
All possibilities with only two characters is still <1000 combinations. At this sort of small number I'd take a guess and say that it would be quicker to use a slightly less efficient algorithm and let the Python internals do the processing on lists than to iterate at Python level.

The reason is that internal Python operations are orders of magnitude faster than a looping construct where the loop is written in Python.

So I'd have a set for the allowed word list, generate a set of permutations and then ask Python for the intersection, rather than iterating through the permutations on the fly.