I have three disjoint lists containing integers: list_a , list_b and list_c . I want to check if any pair of elements, one in list_a and one in list_b exists, such that the list_a element is smaller than the list_b element, and there is no element in list_c that lies between the list_a element and list_b element.
For an example:
list_a = [0, 1, 4, 5, 8]
list_b = [3, 7]
list_c = [2, 6, 9]
We see that 1 < 3, but 2 lies between 1 and 3. Similarly 5 < 7, but 6 lies between 5 and 7.
Therefore, the condition should result as false with these three lists.
However, if we had the following three lists:
list_a = [0, 1, 4, 5, 8]
list_b = [3, 7]
list_c = [6, 9]
the condition should hold true, because 1 < 3, and there is no element in list_c that lies between 1 and 3.
I am unable to think of a way to check for this condition without using for/while loops, which I want to avoid. How can I check for this condition in a concise single-line statement?
Thank you.
Aucun commentaire:
Enregistrer un commentaire