I have a series of lists with 7 elements (but could be any number). I am trying to find the lists that have all positive elements, all negative elements, and those that change sign at ANY point,
for example [3, 6, 7, -2, -5, -1, -1]
or [3, 1, -1, -2, -1, -5, -1]
.
Note that, though I used integers
in my example, the lists
are actually made of floats
.
I can easily find all lists that are always positive or negative, but how do I find those that change sign (it could go from positive to negative as in example or from negative to positive).
source https://stackoverflow.com/questions/72320439/find-sequences-where-all-elements-have-same-sign-and-then-change-sign
Comments
Post a Comment