Created
December 9, 2022 12:25
-
-
Save JohannesBuchner/969b9d8b106be49b27e5de735d59d563 to your computer and use it in GitHub Desktop.
Check whether two intervals overlap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def interval_overlap(alo, ahi, blo, bhi): | |
# interval a: alo to ahi | |
# interval b: blo to bhi | |
return (blo < ahi and bhi > alo) or (alo < bhi and ahi > blo) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment