Hello, I’m trying to use itertools product to generate a list where on the first place is any value from first sublist, on the second - from second, etc.
So, a couple of examples if I had this list: [[‘a’, ‘b’, ‘c’], [‘d’, ‘e’], [‘1’, ‘2’]]
Hi Daan, I was using the list.combine node, however I need to create memory dumps for the code to work, otherwise the code can go way above 32GB of RAM usage and crash my Dynamo. Thats why I was using python: to be able to delete variables after using them.
My initial input is a list of surfaces.
I then divide that list in several sublists of “n” length. In the previous print case, the length is 3.
Afterwards, I want to create all possible combinations of items in the new list, without combining items from the same sublist.
As stated in the first example:
If I had this list: [[‘a’, ‘b’, ‘c’], [‘d’, ‘e’], [‘1’, ‘2’]]
I wanted to get the following combinations:
You are correct. As you concluded, I don’t need different orders of an established combinations, meaning that I want [A, D, 1], but not [A,1,D], [D,1,A], [D,A,1], [1,D,A] and [1,A,D].
I forgot that the previous uploaded dyn file required data from an excel file. It probably didn’t run on your computers.
Here is a new dyn file without the excel nodes: testing2.dyn (82.1 KB)
Itertools returns a custom object as a class to reduce the memory consumption when used elsewhere in Python. Wrap it in a List(*) where * is the entire itertools function. Note this will return all iterations not just one, so you may need a get item at index method if you only want one option.
You may have a few longevity/stability issues to address as well - my attempt to run your graph produced a few errors in the python.