def calc_boundary_perimeter(rectangles):
# find external perimeter of all rectangles
external_perimeter = 0
for rect in rectangles:
x1, y1, x2, y2 = rect
external_perimeter += abs(x2 - x1) + abs(y2 - y1)
# find internal perimeter of overlapping rectangles
internal_perimeter = 0
for i, rect1 in enumerate(rectangles):
for rect2 in rectangles[i+1:]:
if is_overlapping(rect1, rect2):
overlap = calc_overlap(rect1, rect2)
internal_perimeter += 2 * (abs(overlap[0] - overlap[2]) + abs(overlap[1] - overlap[3]))
return external_perimeter, internal_perimeter
```
Created
March 26, 2023 05:37
-
-
Save sxhmilyoyo/1f757dffca51e997836ccc6913384f43 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment