Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First oop solution in Clear category for Interesting, intersecting by ssk8
def overlap(a1: int, a2: int, b1: int, b2: int) -> bool:
return a1<=b1<=a2 or a1<=b2<=a2 or b1<=a1<=b2 or b1<=a2<=b2
class Square:
def __init__(self, x: int, y: int, l: int) -> None:
self.x = (x, x + l)
self.y = (y, y + l)
def intersect(self, other) -> bool:
return overlap(*self.x, *other.x) and overlap(*self.y, *other.y)
def squares_intersect(s1: tuple[int, int, int], s2: tuple[int, int, int]) -> bool:
return Square(*s1).intersect(Square(*s2))
Oct. 22, 2022
Comments: