Skip to content

Instantly share code, notes, and snippets.

@niconico25
Last active January 5, 2019 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niconico25/0a6e2b8f41830982e4afb81ee059d546 to your computer and use it in GitHub Desktop.
Save niconico25/0a6e2b8f41830982e4afb81ee059d546 to your computer and use it in GitHub Desktop.
class Line(object):
def __init__(self, a, b):
self.a = a
self.b = b
def __eq__(self, other):
return all((
self.a == other.a,
self.b == other.b
))
def __le__(self, other):
return all((
other.a <= self.a <= other.b,
other.a <= self.b <= other.b,
))
def __lt__(self, other):
return all((
self != other,
self <= other,
))
assert Line(3, 4) < Line(1, 6)
assert Line(4, 9) < Line(4, 10)
assert Line(4, 9) < Line(3, 9)
assert not(Line(7, 8) < Line(7, 8))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment