Last active
January 5, 2019 18:12
-
-
Save niconico25/0a6e2b8f41830982e4afb81ee059d546 to your computer and use it in GitHub Desktop.
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
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