We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I think the important python learning here is that while the docs only give product() examples with two iterables, product() can take an arbitrary list of iterables to produce all combinations. E.g., modifying an example from the docs:
Maximize It!
You are viewing a single comment's thread. Return to all comments →
I think the important python learning here is that while the docs only give product() examples with two iterables, product() can take an arbitrary list of iterables to produce all combinations. E.g., modifying an example from the docs:
This then lets us create the things to sum over and test for max all at once.
It should be noted that product() isn't magical with respect to run time, this is still a polynomial algorithm in O(n^K).