I want to pseudo-randomly select items from a list and put them into equal-length branches without any duplicates.
I’m wondering if this can be done simply with native Gh components? Currently, I’m doing it with a python script, but that just seems so unnecessary. The last group can have less than the others, accounting for a list length that isn’t perfectly divisible by the number of divisions.
Here’s the important bit (x is geo, y is # of divisions):
import random as ra
import ghpythonlib.treehelpers as th
output = 
div = int(len(x)/y)
for i in range(y):
temp = 
for j in range(div):
num = ra.randrange(0, len(x)-1)
if num == 0:
output = th.list_to_tree(output, source=[0,0])
a = output