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 Chebyshev distance to Point

Thank you 2022 Day 9.

authored by

Kevin Yap and committed by
GitHub
2094a7c3 c5bb800c

+14
+14
2022/utils.py
··· 470 470 471 471 def dist_manhattan(self, other): 472 472 return abs(self.x - other.x) + abs(self.y - other.y) 473 + 474 + def dist_chess(self, other): 475 + return max(abs(self.x - other.x), abs(self.y - other.y)) 476 + 477 + def dist_chebyshev(self, other): 478 + return self.dist_chess(other) 473 479 474 480 def angle(self, to=None): 475 481 if to is None: ··· 492 498 @property 493 499 def manhattan(self): 494 500 return abs(self.x) + abs(self.y) 501 + 502 + @property 503 + def chess(self): 504 + return max(abs(self.x), abs(self.y)) 505 + 506 + @property 507 + def chebyshev(self): 508 + return self.chess 495 509 496 510 @property 497 511 def length(self):