I want to partition a list of positive numbers in sequential order so that sum
of each partition will not be greater than a constant.
for example, to partition sequentially the following list into sum of not
greater than 30
]a=. 3+?.20#7
9 6 3 4 5 5 3 7 9 8 7 3 9 9 6 3 5 7 8 9
the index of cut can be found to be
b=. 0 5 9 13 18
(b e.~ i.#a) <;.1 a
+---------+-------+-------+---------+---+
|9 6 3 4 5|5 3 7 9|8 7 3 9|9 6 3 5 7|8 9|
+---------+-------+-------+---------+---+
+/&> (b e.~ i.#a) <;.1 a
27 24 27 30 17
How to do it, preferably in tacit form?
--
regards,
bill
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm