From a3a97f9c001ba5445b54b07cc42fc32ade08facc Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Mon, 24 Sep 2018 15:27:08 +0200 Subject: [PATCH] Lol --- h2/mbc.py | 21 +++++++++++++++++++++ h2/sidedness.py | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 h2/mbc.py diff --git a/h2/mbc.py b/h2/mbc.py new file mode 100644 index 0000000..d00a1de --- /dev/null +++ b/h2/mbc.py @@ -0,0 +1,21 @@ +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 + \ No newline at end of file diff --git a/h2/sidedness.py b/h2/sidedness.py index 6943214..40ddc25 100644 --- a/h2/sidedness.py +++ b/h2/sidedness.py @@ -55,7 +55,7 @@ def graham_scan(points): # A funky issue where both a and b become negative in the sidedness test causes us to have to use # Side.ABOVE for both tests, regardless of UH or LH. - sorted_points = sorted(points, key=lambda p: p.x) + sorted_points = sorted(points) UH = sorted_points[:2] #del sorted_points[0]