Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
This is interesting, especially for the use of the nested defaultdics. I wonder if we could avoid using permutations and use combinations instead to cut in half the innermost loop (by adding the appropriate extra assignment for result)