Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
native_rectangles_union solution in Uncategorized category for Rectangles Union by Jon_Red
def rectangles_union(recs:[(int)])->int:
return len({
(x,y)for xa,ya,xb,yb in recs for x in range(xa,xb)for y in range(ya,yb)
})
if __name__ =='__main__':
# self-checks
assert rectangles_union([(6,3,8,10),(4,8,11,10),(16,8,19,11)])==33
assert rectangles_union([(16,8,19,11)])==9
assert rectangles_union([(16,8,19,11),(16,8,19,11)])==9
assert rectangles_union([(16,8,16,8)])==0
assert rectangles_union([])==0
July 5, 2020