Grasshopper

algorithmic modeling for Rhino

Hey

 

i have N elements list and i want to create a definition that allows relist them in any possible order(no repeat). 

 

Expample: By 3 points {0,1,2} v(variation number)=3!

 

Result i'm looking for is

 

v=0 - 0,1,2

v=1 - 0,2,1

v=2 - 1,2,0
v=3 - 1,0,2
v=4 - 2,0,1
v=5 - 2,1,0

 

Result order is not important.

 

Would be grafetul for any help! :)

 

Pascal definition:

for i:=0 to 2 do
  for j:=0 to 2 do  
    for k:=0 to 2 do
       begin
          write(i,j,k);
          writeln
       end;

Views: 1359

Replies to This Discussion

Cool thats. If i wanted to find permutations of arrays ?  How should i change the script ?

474 :)

replace letters with numbers then either:

or... at the end of the sub put this in: 

Dim charTree As DataTree(Of Char) = charFN(permList)

A = charTree

Function charFN(ByVal permList As List(Of String)) As DataTree(Of Char)
Dim tTree As New DataTree(Of Char)
For i As Int32 = 0 To permList.Count - 1
Dim nPath As New GH_Path(i)
tTree.AddRange(permList(i).ToList, nPath)
Next
Return tTree
End Function

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service