Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Three Points Circle by swagg010164
import re
from math import sqrt
from decimal import *
def round_norm(n):
number = Decimal(n)
number = number.quantize(Decimal("1.00"))
if number - int(number) == 0:
return int(number)
if (number*100) % 10 == 0:
number = number.quantize(Decimal("1.0"))
return number
def checkio(data):
a = list(map(int, re.findall(r'\d', data)))
x1, y1, x2, y2, x3, y3 = a[0], a[1], a[2], a[3], a[4], a[5]
A, B, C, D = x2 - x1, y2 - y1, x3 - x1, y3 - y1
E = A*(x1 + x2) + B*(y1 + y2)
F = C*(x1 + x3) + D*(y1 + y3)
G = 2*(A*(y3 - y2) - B*(x3 - x2))
x = (D*E - B*F)/G
y = (A*F - C*E)/G
r = round_norm(sqrt((x - x3)**2 + (y - y3)**2))
s = "(x-{})^2+(y-{})^2={}^2".format(round_norm(x), round_norm(y), r)
return s
Dec. 4, 2018