grasshopper2 Rhinorhino3d.com
ComponentData
Permutations
00000000-ec4e-4616-98b1-cbb7ff9291de

Create all permutations of a list, up to a given limit. The number of permutations equals the factorial of the list length, meaning it increases even more rapidly than exponential growth. A list of three values yields 6 permutations, four values yield 24 permutations, and ten values yield over 3.5 million permutations.

Due to this excessive expansion, the component requires a limiting integer to be specified as the second input. This limit is set to 1000 by default, meaning that the amount of output permutations for lists with seven or more elements will already be truncated. Increase this limit at your own peril.

The permutations are generated using a structured algorithm which yields a very predictable sequence. However, the optional Rd input of the component accepts a random engine which will shuffle the order of the output permutations. This is particularly useful if the number of possible permutations exceeds the chosen limit, as it allows for the creation of different subsets of permutations. By default, this input is set to contain a standard random engine. However, in the example file below it has been removed, in order to showcase the structured output.

Note that the input list is not treated as a mathematical set. I.e. identical values are not fungible as far as the permuter is concerned. The total sequence of permutations of the list [A,A,B] covers [A,A,B], [A,B,A], [A,A,B], [B,A,A], [A,B,A], [B,A,A], despite the fact that this sequence contains only three unique lists.

1
2
3
3
Example file Permutations.ghz.Interactive in Grasshopper 2
Create permutations of sets with up to five members.