Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
min max solution in Clear category for Interesting, intersecting by Sim0000
def squares_intersect(s1: tuple[int, int, int], s2: tuple[int, int, int]) -> bool:
f = lambda x1, d1, x2, d2: min(x1 + d1, x2 + d2) - max(x1, x2)
(x1, y1, l1), (x2, y2, l2) = s1, s2
return f(x1, l1, x2, l2) >= 0 and f(y1, l1, y2, l2) >= 0
print("Example:")
print(squares_intersect((2, 2, 3), (5, 5, 2)))
assert squares_intersect((2, 2, 3), (5, 5, 2)) == True
assert squares_intersect((3, 6, 1), (8, 3, 5)) == False
assert squares_intersect((3000, 6000, 1000), (8000, 3000, 5000)) == False
print("The mission is done! Click 'Check Solution' to earn rewards!")
Oct. 19, 2022