My Advent of Code solutions in Python. kevinyap.ca/2019/12/going-fast-in-advent-of-code/
advent-of-code python
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add more magic methods to Point class

+12
+12
2016/utils.py
··· 10 10 def __add__(self, other): 11 11 return Point(self.x + other.x, self.y + other.y) 12 12 13 + def __sub__(self, other): 14 + return Point(self.x - other.x, self.y - other.y) 15 + 16 + def __mul__(self, n): 17 + return Point(self.x * n, self.y * n) 18 + 19 + def __div__(self, n): 20 + return Point(self.x / n, self.y / n) 21 + 22 + def __neg__(self): 23 + return Point(-self.x, -self.y) 24 + 13 25 def __eq__(self, other): 14 26 return self.x == other.x and self.y == other.y 15 27