See in between tekst.
R.E. Boss > -----Oorspronkelijk bericht----- > Van: [email protected] [mailto:programming- > [email protected]] Namens Raul Miller > Verzonden: donderdag 4 augustus 2011 14:24 > Aan: Programming forum > Onderwerp: Re: [Jprogramming] complicated sums of subarrays > > On Wed, Aug 3, 2011 at 9:37 AM, R.E. Boss <[email protected]> wrote: > > A=. 0 1 1 2 3 3 3 4 4 5 , 2 2 3 4 4 4 5 5 , 3 4 5 6 , 4 > > B=. 14 16 8 6 5 8 6 16 16 19 13 12 3 1 9 12 17 0 9 5 17 7 9 > > > > Required: > > array C, by taking array B and add each element of B, corresponding > > with element x in A, to all the next elements of B which correspond to > > elements y in A with x<y and such that for all z in A placed between x > > and y, you have x<z. > > > 14 30 22 28 33 36 34 50 50 69 35 34 37 38 46 49 66 49 43 48 65 72 52 > > I am having a problem understanding this description. > > The first element of both B and C is 14. Why did you not include the second > element of B in the first element of C? > > Here, x would be 0, y would be 1 and z would be trivial. > " add each element of B, corresponding with element x in A, to all the NEXT elements of B which CORRESPOND to elements y in A " So the first element of B has to be added to the second, not the other way around. Perhaps I should have stated: " corresponding with element NUMBER x in A, to all the next elements of B which correspond to element NUMBERS y in A with x<y and such that for all element NUMBERS z in A " but I thought that was obvious from the word "placed". I always try to give specifications in normal text, which is a challenge by itself. > Does this mean that you have an additional requirement that z must come > from a non-empty set? > > So.. ok, but how about the fourth element of B (which is an 6). Here, x would > be 0, y would be 2 and z would always be 1. > > So... perhaps an additional requirement is that the index of y must be > less than the index of x? Or perhaps this was the only requirement? > But if so, how can the second element of C be 30? Or perhaps only adjacent > values from B can be considered -- once one value is excluded all subsequent > ones are excluded. > > Perhaps I should just ignore the description and work from the code? > I presume that that is what Stefano has done? > > Thanks, > > -- > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
