Skip to content

Instantly share code, notes, and snippets.

Created Feb 9, 2018
What would you like to do?
class interval:
def init(low, hi):
self.low = low
self.hi = hi
# bad version
def intersect(oth):
if self.low <= oth.low:
if self.hi < oth.low:
return interval(0,0)
elif: oth.hi <= self.hi:
return self
return interval(oth.min,self.max)
elif self.hi >= oth.hi:
if self.low > oth.hi:
return interval(0,0)
elif: oth.low >= self.low:
return oth
return interval(oth.max,self.min)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment