Group list by the Sum of those list not exceeding the given value

I want to Group the List by those Sum not exceeds the given value(eg:740) irrespective of the list sequence.
see the attached image so that you can understand clearly.

Please Help me out!

Thank you in Advance!

try this:

python code:

# Import python library
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import os
import shutil
import math
# Import math library
from math import *

list1 = IN[0]
maxvalue = IN[1]

i,val = 0,0
ind = []

for l in range(0,len(list1)):
	val = val + list1[i]
	if (val>maxvalue):
		val = list1[i]
		ind.append(list1[:i])
		list1 = list1[i:]
		i = 0
	if i == len(list1)-1: 
		ind.append(list1)
        break		
	i = i + 1

#Final output
OUT = ind
1 Like

Thank you for the Respose @stillgotme

i tried it with your python, but im getting the Empty List with no error.

please see the image below!

convert your list to number first

The bim4struc package has some good bin packing nodes as well if you don’t want to have to worry about maintaining that Python over time.

Thank you @JacobSmall for you Help.
The Node " First Fit Decreasing Bin Packing " from BIM4Struc Package has done with my Requirement!

even i got the Indices, Thank you.

Have a good day!

1 Like