- Python3.9 or higher. I used PyPy3.9 for its speed.
- Understand the problem.
- Think about how to reduce the search space.
- Think if spaces are part of the solution. If yes then how many?
- Think about what data structures can help.
- CPython is slow. Use JIT compiler. PyPy3
- Load the wordlist and remove potential duplicate words.
- Keep only words that can be part of the anagram. This reduced the number of words from 99 175 to 1659 words.
- Use Trie structure to store the 1659 words. This allows for efficient anagrams generation. For more details see "The Algorithm Design Manual", 3rd Edition by Steven Skiena page 448.
- Check for hash collision against the target hashes.
- Run with this command (CPython):
python3.9 main.py wordlist task --log INFO
. - Log is optional arg and values can be
[DEBUG | INFO | WARNING | ERROR | CRITICAL]
default isWARNING
- For PyPy3 run with this command:
pypy3.9 main.py wordlist task --log INFO
See the results.txt file