Skip to content

Instantly share code, notes, and snippets.

@MM-coder
Created October 12, 2019 10:26
Show Gist options
  • Save MM-coder/6d2e6056b58ec07ccd335e9326f7c8e2 to your computer and use it in GitHub Desktop.
Save MM-coder/6d2e6056b58ec07ccd335e9326f7c8e2 to your computer and use it in GitHub Desktop.
Python program to calculate if a interval intersects (2 tuples)
def interval_intersect(a, b, c, d):
if (c <= b) and (a <= d) == False:
return False
else:
return True
def process(input: bool):
if input == False:
return "does not"
else:
return "does"
a = int(input("Value for a: "))
b = int(input("Value for b: "))
c = int(input("Value for c: "))
d = int(input("Value for d: "))
print(f"The interval [{a},{b}] [{c},{d}] does {process(interval_intersect(a, b, c, d))} intersect")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment