iasdf
This commit is contained in:
parent
0fe7e86519
commit
b08be585bc
1 changed files with 11 additions and 10 deletions
21
727.py
21
727.py
|
@ -1,6 +1,7 @@
|
||||||
import sympy
|
import sympy
|
||||||
import joblib
|
import joblib
|
||||||
import tqdm
|
import tqdm
|
||||||
|
import multiprocessing
|
||||||
|
|
||||||
def gcd(a, b):
|
def gcd(a, b):
|
||||||
if b == 0: return a
|
if b == 0: return a
|
||||||
|
@ -44,7 +45,6 @@ def inv_law_cosines(a, b, c):
|
||||||
# given a, b, c return C
|
# given a, b, c return C
|
||||||
return sympy.acos((a * a + b * b - c * c) / (sympy.S(2) * a * b))
|
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:
|
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)
|
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)
|
CAmid = lerp(C, A, r3)
|
||||||
D = circumcenter(ABmid, BCmid, CAmid)
|
D = circumcenter(ABmid, BCmid, CAmid)
|
||||||
|
|
||||||
re = sympy.symbols("re")
|
result = r1 + r2 + r3 + sympy.S(2) * sympy.sqrt(r1 * r2 + r2 * r3 + r1 * r3)
|
||||||
t1 = heron(r1 + r3, r1 + re, r3 + re)
|
# re = sympy.symbols("re")
|
||||||
t2 = heron(r1 + r2, r1 + re, r2 + re)
|
# t1 = heron(r1 + r3, r1 + re, r3 + re)
|
||||||
t3 = heron(r2 + r3, r2 + re, r3 + re)
|
# t2 = heron(r1 + r2, r1 + re, r2 + re)
|
||||||
tfull = heron(r1 + r2, r1 + r3, r2 + r3)
|
# t3 = heron(r2 + r3, r2 + re, r3 + re)
|
||||||
eq = sympy.Eq(t1 + t2 + t3, tfull)
|
# tfull = heron(r1 + r2, r1 + r3, r2 + r3)
|
||||||
result = sympy.solve(eq, re)
|
# eq = sympy.Eq(t1 + t2 + t3, tfull)
|
||||||
result = result[0].evalf()
|
# result = sympy.solve(eq, re)
|
||||||
|
# result = result[0].evalf()
|
||||||
# print(f"radius of E is {result}")
|
# print(f"radius of E is {result}")
|
||||||
|
|
||||||
EAB = inv_law_cosines(r1 + result, r1 + r2, r2 + 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}")
|
print(f"d({r1}, {r2}, {r3}) = {d}")
|
||||||
|
|
||||||
total = len(list(create_loop()))
|
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))
|
print(sum(L) / len(L))
|
||||||
|
|
Loading…
Reference in a new issue