>From the hip:
([:((]`(0:,])@.(30<:]))@(+{.),[,[EMAIL PROTECTED])/,&0)&.|. 9 6 3 4 5 5 3
7 9 8 7 3
9 9 6 3 5 7 8 9 NB. line wrap
9 6 3 4 5 5 32 3 7 9 8 7 34 3 9 9 6 3 30 5 7 8 9 29
the subsums >: 30 and the final subsum are inserted.
R.E. Boss
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED] [mailto:programming-
> [EMAIL PROTECTED] Namens bill lam
> Verzonden: vrijdag 24 augustus 2007 12:30
> Aan: Programming forum
> Onderwerp: [Jprogramming] sequential partition
>
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm