algorithmic modeling for Rhino
Say I have a list as follows:
{0}
1. CAT
2. DOG
3. TREE
and I want to get every possible combination that does not necessarily use all the indices. Essentially I want a tree that would look like this:
{0}
1.CAT
2.DOG
3.TREE
{1}
1.CAT
2.DOG
{2}
1.CAT
{3}
1.DOG
2.TREE
{3}
1.DOG
{4}
1.TREE
{5}
1.CAT
2.TREE
Can cross reference be used to produce a tree like this?
Tags:
A simple/terse solution to this class of problem, might be to use the permutations function found in the standard itertools module in Python. Note that it might not scale super well with large input sets, due to the cost of outputting large amount of data from the GHPython component. Attached this example:
Edit: Mohamed beat me to it :)
There is also something called Variation
repeating elements the same length as the places like this (c,c,c,b,b,b,c,c,c) give as result like (cat, cat, cat) or zero as an option
adding empty value to variations elements (" ", "a", "b", "c") give us values like (cat) or (cat, cat)
You can say I have all variations of (a,b,c) like a, ab, abc
but I guess when you use the word combination you say all possible unique combinations in two places ([][])out of 3 elements (a,b,c)
(ab = ba)
but for permutations, you say all possible permutations for two places ([][]) from a pool of 3 elements (a,b,c)
(ab != ba)
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by