I have a python list of ints, a
. I also have another list, b
, which is a tuple of 2 values (c, d)
. I need to see if any elements of a
have values that are between any of the tuple elements of b
.
I think there is a way to do this using map()
, but I can't figure out how to pass in the values of my tuple list.
For example, my data structure looks like:
a = [1, 2, 3, 4, 5, 6, 7]
b = [(12,14), (54, 78), (2,3), (9,11)]
I am trying to find out if any of the elements in a
have values between any of the tuple elements of b
. In the above case, 2
and 3
(from a
) are inside (inclusive) of the tuple (2,3)
in b
. So my final answer would be True
.
Does anyone have any idea how to do this in a performat way? Right now, I am looping through each element of a
and then looping through each element of b
. This is ok for small amounts of data, but my arrays are quite large and this step takes way to long.