From b08be585bc699d5fbb8060669fb541637ad3f3e3 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Mon, 7 Dec 2020 19:41:32 -0600 Subject: [PATCH] iasdf --- 727.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/727.py b/727.py index b8be33a..76f9edb 100644 --- a/727.py +++ b/727.py @@ -1,6 +1,7 @@ import sympy import joblib import tqdm +import multiprocessing def gcd(a, b): if b == 0: return a @@ -44,7 +45,6 @@ def inv_law_cosines(a, b, c): # given a, b, c return C return sympy.acos((a * a + b * b - c * c) / (sympy.S(2) * a * b)) - def compute_d(A: Point, B: Point, C: Point, r1: float, r2: float, r3: float) -> float: r1, r2, r3 = sympy.S(r1), sympy.S(r2), sympy.S(r3) @@ -53,14 +53,15 @@ def compute_d(A: Point, B: Point, C: Point, r1: float, r2: float, r3: float) -> CAmid = lerp(C, A, r3) D = circumcenter(ABmid, BCmid, CAmid) - re = sympy.symbols("re") - t1 = heron(r1 + r3, r1 + re, r3 + re) - t2 = heron(r1 + r2, r1 + re, r2 + re) - t3 = heron(r2 + r3, r2 + re, r3 + re) - tfull = heron(r1 + r2, r1 + r3, r2 + r3) - eq = sympy.Eq(t1 + t2 + t3, tfull) - result = sympy.solve(eq, re) - result = result[0].evalf() + result = r1 + r2 + r3 + sympy.S(2) * sympy.sqrt(r1 * r2 + r2 * r3 + r1 * r3) + # re = sympy.symbols("re") + # t1 = heron(r1 + r3, r1 + re, r3 + re) + # t2 = heron(r1 + r2, r1 + re, r2 + re) + # t3 = heron(r2 + r3, r2 + re, r3 + re) + # tfull = heron(r1 + r2, r1 + r3, r2 + r3) + # eq = sympy.Eq(t1 + t2 + t3, tfull) + # result = sympy.solve(eq, re) + # result = result[0].evalf() # print(f"radius of E is {result}") EAB = inv_law_cosines(r1 + result, r1 + r2, r2 + result) @@ -104,5 +105,5 @@ def calc(x): print(f"d({r1}, {r2}, {r3}) = {d}") total = len(list(create_loop())) -L = joblib.Parallel(n_jobs=8)(joblib.delayed(calc)(tup) for tup in tqdm.tqdm(create_loop(), total=total)) +L = joblib.Parallel(n_jobs=multiprocessing.cpu_count())(joblib.delayed(calc)(tup) for tup in tqdm.tqdm(create_loop(), total=total)) print(sum(L) / len(L))