On 19 Sep 2005 00:02:34 -0700, malv <[EMAIL PROTECTED]> wrote: > Simple case: > In this list, how to find all occurences of intervals of n adjacent > indexes having at least one list-member with a value between given > limits. > Visualizing the list as a two-dimensional curve, this is like > horizontally dragging a given rectangle over the curve and finding the > x coordinates where the curve passes through the rectangle.(Define such > a x-index coordinate as the left corner of the rectangle.) > > More complicated case: > Given a pair of rectangles spaced relatively to each other in a fixed > manner. Drag this rectangle pair horizontally over the above > two-dimensional curve and list the indexes of the occurences where the > curve passes simultaneously through both rectangles. > (Define such a x-index coordinate as the leftmost corner of the > rectangle pair). > > These problems can be solved by programming a naive search advancing > index by index. It seems obvious that due to the localized properties > searched for, much more efficient searches should be possible. > After having found the occurence-indexes for one particular rectangle > set, how to find the pattern occurences after changing one or more > rectangle parameters? >
Make a picture of the problem. From your description, I'm not certain anything more complicated than a linear search is called for. Is this the phrasing of the original problem presentation? Seems to me the word "superimpose" ought to occur here. Another thought: What is the end result you're after? Often we start thinking of a solution but lose sight of the end result. Then another solution will pop into our mind that makes it Oh So Simple. -- http://mail.python.org/mailman/listinfo/python-list