Skip to content

Instantly share code, notes, and snippets.

@JohannesBuchner
Created December 9, 2022 12:25
Show Gist options
  • Save JohannesBuchner/969b9d8b106be49b27e5de735d59d563 to your computer and use it in GitHub Desktop.
Save JohannesBuchner/969b9d8b106be49b27e5de735d59d563 to your computer and use it in GitHub Desktop.
Check whether two intervals overlap
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