Trying to split up a list based on a list of quantities

Hello:

I have imported a list of values from Excel. Each item describes a room and includes a quantity needed. I will be creating Revit geometry from these items, but the quantities vary quite a bit with some quantities being large, like one of them is 100 for example. So what I want to do is “wrap” the list when it exceeds a given quantity (I am using 10 right now). So in the case of the quantity 100, I want to convert this to 10 items or 10 each instead. I have another that is 15, and one that is 12. So those would be an item of 10, then another of 5, for example.

I was able to repeat the items by their quantities, but I am struggling to split the long quantities into repeat items as I described. Here is an image that I hope clarifies:



Looking at the graph, I feel like I am close, but I am just stuck on how to change the quantities to reflect the duplicates I made. In other words, the first few nodes divide the quantity items, and if then do a ceiling to determine if I need more than one copy of that item. So the 15 quantity yields 2 as an example. (15 divided by 10, would require a row of 10 and a row of 5, so two rows total). I was then able to use List.OfRepeatedItem to make the duplicates in the list. This all works fine, but the quantity still reads 15 for both of these entries. For the rest of the graph downstream, I want it to read quantity 10 for the first entry and quantity 5 for the second. Then later for the 100 quantity, I want them all to say 10 and so on. Does this make sense?

Any assistance is appreciated.

Hi @Paul_Aubin ,
I think the most adapted operator for what you want to do is modulo (it gives the rest of a division).
here’s a proposition:

here is the content of the code block , you can connect it directly to your list from excell

n = List.GetItemAtIndex(l<1>,1);
modulo = n%10;
packs10 = (n-modulo)/10;

a = List.Chop(List.ReplaceItemAtIndex(l<1>,1,modulo<1>),1);
b = List.OfRepeatedItem((List.ReplaceItemAtIndex(l<1>,1,10))<1>,packs10<1>);

list = List.Flatten(List.Transpose({a,b}),2);

//We need to remove the sublist with a 0 value

m = List.GetItemAtIndex(list<1>,1) == 0;

cleanedlist = List.FilterByBoolMask(list,m)["out"];

List.Chop should do the needful.
For lists that are within the length specified it does nothing, for lengths that exceed it chops into sub lists of the specified length.

Thank you both for the suggestions. I had tried List.Chop and was not getting what I needed. But after looking at it again, and trying it again, it seems that List.Chop and a series of List.Map has gotten me much closer. I think I have what I need now! Thank you!