import statistics from collections import namedtuple from typing import List, Set Point = namedtuple('Point', 'x y') def mbc_ch(points: Set[Point]): # Find the point with median x-coordinate, and partition the points on this point pm = statistics.median_high(points) pl = {point for point in points if point.x < pm.x} pr = {point for point in points if point.x >= pm.x} # Find the bridge over the vertical line in pm