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 Phil15
from math import hypot
def checkio(data):
(x1, y1), (x2, y2), (x3, y3) = eval(f'({data})')
a, b = _d(x2, y2) - _d(x1, y1), _d(x3, y3) - _d(x1, y1)
det = (x2 - x1) * (y3 - y1) - (x3 - x1) * (y2 - y1)
x = ((y3 - y1) * a + (y1 - y2) * b) / (2 * det)
y = ((x1 - x3) * a + (x2 - x1) * b) / (2 * det)
r = hypot(x - x1, y - y1)
return '(x-{})^2+(y-{})^2={}^2'.format(*map(_format, (x, y, r)))
_format = lambda x: str(round(x, 2)).rstrip('.0') or '0'
_d = lambda x, y: x ** 2 + y ** 2
Feb. 28, 2020
Comments: